[英]How can I ask for user input in python through the terminal in windows?
[英]How can I ask the user for an input after a conditional?
我正在制作一个预测天气的程序,如果前一个问题的答案是“是”,我需要问用户某个问题,或者如果答案是“否”,我需要问一个不同的问题。 只有当某个条件为True
时,我才能执行输入请求。
您正在寻找一个 if 语句:
firstresponse = input('first (y/n): ')
if firstresponse == 'y':
secondresponse = input('second: ')
print(firstresponse)
print(secondresponse)
else:
print(firstresponse)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.