Im pretty new in python and I want to make a little game to guess the airplane. In the below code i find a problem when "valor_posicion_random" is 2, the problem in the Title appear and I dont know why.
import random
x=0
res=0
lis_av = { 1:"Airbus A380" , 2:"Airbus A340" , 3:"Airbus A330" , 4:"Boeing 777" , 5:"Boeing 787" , 6:"Boeing 747"}
def posicion_random(lis_av, res):
print(lis_av[valor_avion])
if valor_posicion_random == 1:
print("\n 1.",lis_av[valor_avion],"\n 2.",random.choice(lis_av))
elif valor_posicion_random == 2:
print("\n 1." , random.choice(lis_av), "\n 2.",lis_av[valor_avion])
res=int(input("What plane is it?"))
print(lis_av)
while x==0:
valor_avion = random.randint(1,6)
valor_posicion_random = random.randint(1,2)
posicion_random(lis_av, res)
x=int(input("Try again? (1=No//0=Yes)"))
Pd. I'll use PIL to put an image to guess the airplane but for the moment I use the print below the def function to know the airplane Pd2. I am latin, sorry for the latin variables <3