2 回答

TA贡献1770条经验 获得超3个赞
试试这个:
print('What is your name?')
YourName = input()
if YourName == "Alice":
print('Hello Alice')
else:
print('How old are you?')
age = int(input())
if age < 4:
print('And you know how to write at young age!')
和一个单线:
print("Hello Alice") if input("What is your name ")=="Alice" else print('And you know how to write at young age!') if int(input("How old are you? "))<4 else None

TA贡献1810条经验 获得超4个赞
你的代码有问题
欢迎!以下行是错误的:
elif print('How old are you?')
这背后有两个主要原因:
print('How old are you?')不是正常情况。尽管这在技术上很好,因为您的编译器会将其评估为类型None并将其视为 ,但False您可能希望用概念上有意义的内容替换该部分。
你在elif.之后缺少一个冒号。例如:
elif (int(input()) < 4):
#your code
解决方案
print('What is your name?')
YourName = input()
if YourName == "Alice":
print('Hello Alice')
else:
print('You are not Alice! How old are you?')
if int(input()) < 4:
print('You know how to write at young age!')
添加回答
举报