Is there a way to put input into a loop in python 3.8?
I want get to user input multiple times without having to run the program more than once.
I would like to enter a hero and get an answer back and then be able to enter another one without hitting run over and over.
If anyone has any suggestions please let me know.
Thank you!
"""
This program is intended to compare heroes from Marvel and DC. Enter
your
hero choice and see what hero from #Marvel or DC is most like them.
I know there are simpler ways to write this code so if anyone has any
suggestions please leave them for me
Thanks for viewing!
Only the heroes below can be entered
marvel = ['Moon Knight', 'Hyperion', 'Thor', 'Punisher', 'Jean Grey',
'Iron Man', 'Quicksilver']
DC = ['Batman', 'Superman', 'Shazam', 'Red Hood', 'Wonder Woman',
'Batwing', 'Flash']
"""
choice = str(input('Choose a hero\n'))
def hero_choose():
if choice.lower() == 'batman':
return('Moon Knight')
if choice.lower() == 'moon knight':
return('Batman')
if choice.lower() == 'superman':
return('Hyperion')
if choice.lower() =='hyperion':
return('Superman')
if choice.lower() == 'thor':
return('Shazam')
if choice.lower() == 'shazam':
return('Thor')
if choice.lower() == 'red hood':
return('punisher')
if choice.lower() == 'punisher':
return('Red Hood')
if choice.lower() == 'wonder woman':
return('Jean Grey')
if choice.lower() == 'jean grey':
return('Wonder Woman')
if choice.lower() == 'iron man':
return('Batwing')
if choice.lower() == 'batwing':
return('Iron Man')
if choice.lower() == 'flash':
return('Quicksilver')
if choice.lower() == 'quicksilver':
return('Flash')
else:
return('Your hero may not be available\nor your spelling may be
wrong.')
print(hero_choose())