[Tutor] Random Number Game: Returns always the same number - why?
Amit Saha
amitsaha.in at gmail.com
Tue May 21 03:54:15 CEST 2013
Hi Rafael,
On Tue, May 21, 2013 at 2:51 AM, Rafael Knuth <rafael.knuth at gmail.com> wrote:
>
> Your variable assignment for Random_Number is outside of your while
> loop. Therefore its value never changes. Put it inside the while loop
> just before the print statement and I think you will get what you
>
> That was it! Thank you, you made my day, Bob :-)
Here is a visualization of how the lines of your original code are
executed: http://goo.gl/uRRTu. Click on the "Forward" button there to
see the next line of code that is executed. You will see that in your
original code, the statement: "Random_Number = random.randint(1, 100)"
which actually generates your random numbers is executed only once.
Hope that helps your understanding.
Best,
Amit.
--
http://echorand.me
More information about the Tutor
mailing list