This is probably the most ugly code you'll ever see, anyway I need help, cause I didn't get it how loops works. The idea of the script is easy, you put a name of a Superhero and you'll get his real name. Then if you want, you can choose the "biography" section, to get into details.
import sys
import os
super_heros = {'Hulk': 'Bruce Banner', # Creo lista supereroei
'Capitan America': 'Steve Rogers',
'Spiderman': 'Peter Parker'}
hero_biography = {'Bruce Banner': 'David Banner nasce in California. '
'Si laurea con il massimo dei voti in medicina, radiologia, genetica'
'e biologia molecolare. '
'A pochi anni dalla laurea, acquisisce una grande fama come medico in malattie'
'rare e genetiche, nonché come ricercatore in ambito radiologico, cellulare, e '
'atomico. '
'Per anni insegna scienze genetiche a Princeton e a Stanford, dove acquisisce'
'una fama sempre crescente nel campo delle ricerche sugli impulsi emotivi e '
'sui raggi gamma. '
'Le sue ricerche subiscono una grande ispirazione quando legge i primi articoli '
'del dottorRonald Pratt, secondo il quale è possibile ottenere poteri guaritori '
'da una manipolazione genetica. '
'Al termine insegnamento come docente universitario, Banner lavora presso un '
'laboratorio dove è affiancato da Elèna Marks, una vecchia compagna del college',
'Peter Parker' : 'Prova'}
print('Script creato da Federico Di Lembo')
while True: # Loop per condizione soddisfatta
choice = input('Nome Supereroe:')
if choice == 'Hulk':
print(super_heros['Hulk'])
elif choice == 'Capitan America':
print(super_heros['Capitan America'])
elif choice == 'Spiderman':
print(super_heros['Spiderman'])
elif choice == 'Esc': # Imposto uscita dal programma
sys.exit(0)
elif choice == 'Biografia': # Imposto uscita dal loop
break
else:
choice == ''
print('Nome inesistente')
while True: # Imposto Nuovo Loop per la seconda scelta
x = 1
if x > 0:
newchoice = input('Biografia: digitare nome reale del supereroe ==> ')
if newchoice == 'Bruce Banner':
print(hero_biography['Bruce Banner'])
break
elif newchoice == 'Peter Parker':
print(hero_biography['Peter Parker'])
if newchoice == '':
newchoice
while True:
x = 1
if x > 0:
secondnewchoice = input('Desideri continuare la ricerca nella sezione Biografia?')
if secondnewchoice == 'No':
break
if secondnewchoice == 'Si':
newchoice
os.execl(sys.executable, sys.executable, *sys.argv)
In the last part of the code, I don't understand how to "recall" the newchoice input. In the last loop the question is "Would you like to stay in the biography section?", then if your answer is "yes" "Si", I want to refer to newchoiche input, just above. What I'm doing wrong?
I'm sorry for my english.