0

I was just messing around with a simple program like:

    import random
    game = True
    body = ['right foot', 'left foot', 'right hand', 'left hand']
    color = ['red', 'blue', 'green', 'yellow']
    while game:
        userinput = input('What would you like to do?')
        if userinput == '':
            random1 = random.choice(body)
            random2 = random.choice(color)
        print(random1 + ' ' + random2)
    if userinput == 'quit':
        game = False

I was wondering, instead of having the user type in quit, how could I make is so that the program quits when the escape key is pressed?

Remi Guan
  • 21,506
  • 17
  • 64
  • 87
jparikh97
  • 95
  • 1
  • 1
  • 9

0 Answers0