问题是:使用带参数的过程。要求用户输入数字,直到他们说“不”。如果每个数字大于或小于或等于 5,则输出。
def output(number):
if number > 5:
print("Greater than 5")
elif number < 5:
print("Less than 5")
else:
print("It is equal to 5")
userInput = "yes"
print(userInput.lower() != "no")
num = input("Enter a number \n")
output(userInput)
userInput = input("Would you like to try again?")
答案 0 :(得分:-2)
您正在尝试将 str 与 int 进行比较。以下将修复它:
def output(number):
if number > 5:
print("Greater than 5")
elif number < 5:
print("Less than 5")
else:
print("It is equal to 5")
userInput = "yes"
print(userInput.lower() != "no")
num = int(input("Enter a number \n"))
output(userInput)
userInput = input("Would you like to try again?")