print("Hello there")
name=input("What is your name?")
print("Welcome to the some game, " + name + "!")
print("I'm going to ask you some basic questions so that we could work together")
age=input("Your age")
if age >= 14 and age < 41:
print("K")
else:
print("Sorry bruh")
print("Thanks")
输入15时,一直向我显示“对不起”。为什么?怎么了?
答案 0 :(得分:3)
将input
投放到int
:
age = int(input("Your age"))
您可以添加try-except
。您的情况应同等地在or
而不是and
答案 1 :(得分:0)
要么使用Python3,要么使用int(input("Your age"))
进行投射,要么使用Python2,然后需要使用raw_input
来读取名称:name=raw_input("What is your name?")
答案 2 :(得分:0)
好的,所以你可以在python2.7中尝试这个代码,它可以按你的需要工作:
print("Hello there")
name=raw_input("What is your name?")
print("Welcome to the some game, " + name + "!")
print("I'm going to ask you some basic questions so that we could work together")
age=input("Your age")
if age >= 14 and age < 41:
print("K")
else:
print("Sorry bruh")
print("Thanks")