Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #99190

Re: error help import random

From Seymore4Head <Seymore4Head@Hotmail.invalid>
Newsgroups comp.lang.python
Subject Re: error help import random
Message-ID <mn9v4btss3epg7ijle8b8kg2nnqbkip4el@4ax.com> (permalink)
References <8b0ec311-ab7f-429d-877f-d205ad6008d9@googlegroups.com>
Organization blocknews - www.blocknews.net
Date 2015-11-20 18:05 -0500

Show all headers | View raw


On Fri, 20 Nov 2015 09:22:10 -0800 (PST), Dylan Riley
<dylan.riley@hotmail.com> 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
>
A problem I used to have is that if you have a file called random.py
in the folder when you try to import random, it caused an error.

>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

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

error help import random Dylan Riley <dylan.riley@hotmail.com> - 2015-11-20 09:22 -0800
  Re: error help import random Chris Angelico <rosuav@gmail.com> - 2015-11-21 04:30 +1100
  Re: error help import random Peter Otten <__peter__@web.de> - 2015-11-20 18:57 +0100
  Re: error help import random Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-20 11:10 -0700
  Re: error help import random Terry Reedy <tjreedy@udel.edu> - 2015-11-20 15:15 -0500
    Re: error help import random Rob Gaddi <rgaddi@technologyhighland.invalid> - 2015-11-20 23:03 +0000
      Re: error help import random Dylan Riley <dylan.riley@hotmail.com> - 2015-11-20 19:26 -0800
  Re: error help import random Seymore4Head <Seymore4Head@Hotmail.invalid> - 2015-11-20 18:05 -0500

csiph-web