[Tutor] Random Number Game: Returns always the same number - why?
John R Jones
n711az at gmail.com
Mon May 20 18:40:33 CEST 2013
You need to move this line:
Random_Number = random.randint(1, 100)
into the loop body, like this:
while Count <= 100:
Random_Number = random.randint(1, 100)
print (Random_Number)
Count = Count + 1
Hope this helps.
On Mon, May 20, 2013 at 9:31 AM, Rafael Knuth <rafael.knuth at gmail.com>wrote:
> Hello,
>
> I wrote a simple program, and I was expecting that I would get 100
> different random numbers. Instead, I am getting 100 times exactly the same
> random number. Can anyone advise how I should alter my program?
>
> Thank you!
>
> All the best,
>
> Rafael
> PS. I am using Python 3.3.0
>
> print ("""
>
> This game will return 100 random numbers between 1 and 100.
>
> """)
>
> import random
>
> Count = 0
>
> Random_Number = random.randint(1, 100)
>
> while Count <= 100:
> print (Random_Number)
>
> Count = Count + 1
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
--
John R Jones <n711az at gmail.com>
10814 Des Moines Ave, Porter Ranch, CA 91326
818-378-6206 cell/text, 310-531-8300 work, 424-234-9213 voicemail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130520/a638ab3f/attachment.html>
More information about the Tutor
mailing list