0

How do you keep this from repeating "try again" when giving a wrong input:

from __future__ import print_function

print("Hello, World!")

name = input("What is your name?")

hobby = input("Cool, so " + name + " what do you do you for fun? You can say something like play, work, learn, etc.")

actions = {'play': 'awesome', 'work': 'must be busy', 'learn': 'ha, me too', }

while True:
    try:
        print(actions[hobby])
        break
    except KeyError:
        print("Try again.")
AJSMP
  • 1
  • 4

0 Answers0