def keti():
if payf=="y":
print("The fees are {}".format(amount))
if payf == "n":
amount = amount +10
print ("the fees are {}".format (amount ))
def keti2():
if payf=="y":
amount =2*amount
print("The fees are {}".format(amount))
if payf == "n":
amount =2*amount
amount = amount +10
print ("the fees are {}".format (amount ))
ket=int(input("no of kts"))
print(ket)
payf = str(input("hav u paid"))
print (payf)
amount=250
if (ket=="1"):
keti()
elif (ket=="2"):
keti2 ()
else:
print ("wrong input")
这有什么问题? 每次执行其他语句 我不明白这是怎么回事
这有什么问题? 每次执行其他语句 我不明白这是怎么回事
答案 0 :(得分:0)
ket=int(input("no of kts")) # you have converted ket into int object
print(ket)
if (ket=="1"): # here your trying to compare an int object and string object ,try it with ket==1 or ket==int("1")
keti()
elif (ket=="2"):
keti2 ()
else:
print ("wrong input")
您正在将int对象与字符串进行比较,请尝试如果ket == 1:
答案 1 :(得分:0)
您已经将第一个输入转换为int,在这里:
ket = int(input("no of kts"))
因为它是整数,所以正确的比较应该是
if (ket == 1):
...
elif (ket == 2):
...