error help import random

Peter Otten __peter__ at web.de
Fri Nov 20 12:57:44 EST 2015


Dylan Riley wrote:

> This is my fortune cookie program i wrote in python.
> the problem is it will not run past the first line of input.
> could someone please identify the error and explain to me why.
> here is the code:
> 
> #the program silulates a fortune cookie
> #the program should display one of five unique fortunes, at randon, each
> #time its run
> 
> import random
> 
> print("  \\ \\ \\ \\ DYLANS FORTUNE COOKIE \\ \\ \\ ")
> print("\n\n\tGood things come to those who wait")
> input("\nPress enter to see your fortune")
> 
> fortune = random.randrange(6) + 1
> print(fortune)
> if fortune == 1:
>     print("happy")
> elif fortune == 2:
>     print("horny")
> elif fortune == 3:
>     print("messy")
> elif fortune == 4:
>     print("sad")
> elif fortune == 5:
>     print("lool")
> 
> print("hope ypu enjoyed your fortune being told")
> input("\nPress enter to exit")
> 
> 
> many thanks in advance

Make sure that you run your code with Python 3, not Python 2.




More information about the Python-list mailing list