1

Hello everyone checking this out. I'm very new to the world of Python3 language. I'm currently on the 3rd version of building up a simple program to make it more interactive. I'm looking to create a prompt if a user inputs anything besides yes or no into the given field. I have done searches and tried many examples. I'm sure it's something simple I am missing but I'm at a standstill.

print("What's up! My name is Kan Jones. What is your name?")  # customize 
introduction sentence.
myName = input().title()  # Added .title() to capitalize 1st letter of user 
name.

print("Would you like to play a guessing game with me " + myName + "?" + " 
Yes or No?")
userAnswer = input("").title()

if userAnswer == "Yes":
print('Alrighty ' + myName + ', I am thinking of a number between 1 and 
20.')
if userAnswer == "No":
print("Ahwww,well maybe next time. See you later")
exit()  # if user doesn't inputs "no" program exits.

If anyone has input it is greatly appreciated!

kan
  • 11
  • 2
  • The first search result on google gave me https://stackoverflow.com/questions/23294658/asking-the-user-for-input-until-they-give-a-valid-response, what searching have you done? – cs95 Nov 08 '18 at 02:24
  • I actually have this tab (along with about 8 more) open and have tried it with no luck. I'm sure it's something simple that I'm missing but after 2 hours of trying I decided to see if I could get some help. Thanks for your reply. I'll keep at it another time. – kan Nov 08 '18 at 02:49

0 Answers0