如果輸入是數字,我想在我的if
語句中打印公式的結果,如果是字母,則打印"any thing"
。Python - 如果輸入是字母或數字,則顯示不同的輸出
我試過這段代碼,但是效果不好。這裏有什麼問題?
while 1:
print '\tConvert ciliuse to fehrenhit\n'
temp = input('\nEnter the temp in C \n\t')
f = ((9/5)*temp +32)
if temp.isdigit():
print f
elif temp == "quit" or temp == "q" :
break
elif temp.isalpha() :
print ' hhhhhhh '