Though there is probably an easier way to do it, but I wish to understand what is wrong.The code should tell you the real identity of a superhero when given the superhero's name.
Here is the problem:
After you provide the superhero's real name, it would ask "Do you need more information?"; How do you setup a choice for this question?
super_heros = {'Hulk': 'Bruce Banner',
'Capitan America': 'Steve Rogers',
'Spiderman': 'Peter Parker'}
hero_biography = {'Bruce Banner' : 'David Banner nasce in California...ecc'}
while True:
choice = input('Nome Supereroe:') ###Superhero's name:
if choice == 'Hulk':
print(super_heros['Hulk'])
elif choice == 'Bruce Banner':
choice = input('Desideri maggiori informazioni?') ###Do you want more information
elif choice == 'Yes': ### I know that this one will refer to : choice = input('Nome Supereroe:')
print(hero_biography['Bruce Banner'])
elif choice == 'Capitan America':
print(super_heros['Capitan America'])
elif choice == 'Spiderman':
print(super_heros['Spiderman'])
elif choice == 'Esc':
break
else:
choice == ''
print('Nome inesistente')
Use a nested condition with another variable, e.g. choice2
...
elif choice == 'Bruce Banner':
choice2 = input('Desideri maggiori informazioni?')
if choice2 == "Yes":
print(hero_biography['Bruce Banner'])
elif choice == 'Captain America':
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With