i am literally an absolute beginner in programming so i would be very grateful if someone could help me out. my program looks like this:
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")
it functions exactly the way i want it to but i want add a feature.i want it to ask allow the user to answer 'why do you want to ride the roller coaster'.
To ask a question for the user to answer, instead of saying
print("Why do you want to ride the roller coaster")
(which just displays something on the screen rather than asking the user a question) you can use the built-in input()
function. So you can replace the line that has
print("Why do you want to ride the roller coaster")
with
yourVariableName = input("Why do you want to ride the roller coaster? ")
Then you can respond to the user's answer:
print("Your message here")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.