我如何让我的程序向用户提出更多问题?
How do i make my program ask further questions to the user?
我确实是编程的初学者,所以如果有人能帮助我,我将不胜感激。
我的程序是这样的:
age = input("Your Age:")
ageNum = int(age)
if ageNum >= 18:
print("Why do you want to ride the roller coaster")
else:
print("You are not allowed to ride the roller coaster")
它的功能完全符合我的要求,但我想添加一个 feature.i 希望它允许用户回答 'why do you want to ride the roller coaster'.
提出问题让用户回答,而不是说
print("Why do you want to ride the roller coaster")
(它只是在屏幕上显示一些内容,而不是向用户询问问题)您可以使用内置的 input()
函数。所以你可以替换具有
的行
print("Why do you want to ride the roller coaster")
和
yourVariableName = input("Why do you want to ride the roller coaster? ")
那么您可以回复用户的回答:
print("Your message here")
我确实是编程的初学者,所以如果有人能帮助我,我将不胜感激。 我的程序是这样的:
age = input("Your Age:")
ageNum = int(age)
if ageNum >= 18:
print("Why do you want to ride the roller coaster")
else:
print("You are not allowed to ride the roller coaster")
它的功能完全符合我的要求,但我想添加一个 feature.i 希望它允许用户回答 'why do you want to ride the roller coaster'.
提出问题让用户回答,而不是说
print("Why do you want to ride the roller coaster")
(它只是在屏幕上显示一些内容,而不是向用户询问问题)您可以使用内置的 input()
函数。所以你可以替换具有
print("Why do you want to ride the roller coaster")
和
yourVariableName = input("Why do you want to ride the roller coaster? ")
那么您可以回复用户的回答:
print("Your message here")