0

Im making a program for my intro to python class project. Its a pokedex. I have everything setup but my friend brought up the fact that when he entered any non number or number over 151 would crash the program. I tried to do an elif statement to see if it isalpha() but when i tried it, it would print this error.

Traceback (most recent call last):
  File "python", line 712, in <module>
  File "<string>", line 1, in <module>
NameError: name 'a' is not defined

so i just need help stopping it from crashing when it has any input thats not valid. the full prgram is on this Link

#should define it here 
def print_userpoke_details(userpoke):
#take a parameter,the user input

    if userpoke == 1:
        print(Bulbasaur)
    elif userpoke.isalpha():
        print ("You did not enter a valid number")

while True:
    userpoke = input("Pokémon #:")
    #call the function here with user input
    print_userpoke_details(userpoke)
Ma0
  • 15,057
  • 4
  • 35
  • 65

0 Answers0