Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Python (http://www.programmingforums.org/forum43.html)
-   -   While Loop Freezes (http://www.programmingforums.org/showthread.php?t=1217)

mfo6463 Nov 20th, 2004 10:40 AM

:

power = 0
result = 0
while result <= dec:
 * *result = 2 ** power
 * *power = power + 1
print power
print result

When it gets to the while loop, it freezes. Why does it freeze and how can I fix it?

thechristelegacy Nov 20th, 2004 11:27 AM

It's becuase the variable dec hasn't been defined (as far as I can see from your example, unless there is more code...?

tempest Nov 20th, 2004 11:45 AM

When things freez you have to put them in a microwave on defrost, or put them in front of a fire or something. One time my toe froze and i had to put it next to the fire to bring back circulation... it was disgusting...

http://www.feetnet.com/edu/toenail/images/ingrown3.jpg

mfo6463 Nov 20th, 2004 12:03 PM

Quote:

Originally posted by thechristelegacy@Nov 20 2004, 12:27 PM
It's becuase the variable dec hasn't been defined (as far as I can see from your example, unless there is more code...?
Yea, I forgot the first line.
:

dec = raw_input("Number: ")
power = 0
result = 0
while result <= dec:
 * *result = 2 ** power
 * *power = power + 1
print power
print result


Ooble Nov 20th, 2004 12:14 PM

Thanks for the lovely pic, Tempest...

Beegie_B Nov 20th, 2004 1:02 PM

Quote:

Originally posted by mfo6463@Nov 20 2004, 06:03 PM
:

dec = raw_input("Number: ")
power = 0
result = 0
while result <= dec:
  result = 2 ** power
  power = power + 1
print power
print result


It's because dec is a string variable because of the "raw_input" command.

Just try:
:

dec = input("Number: ")
That should fix your problem

And tempest, nice pic :puke:
Beeg

mfo6463 Nov 20th, 2004 2:53 PM

Quote:

Originally posted by Beegie_B@Nov 20 2004, 02:02 PM
It's because dec is a string variable because of the "raw_input" command.
Thanks, I didnt notice that.

Infinite Recursion Nov 20th, 2004 8:01 PM

Glad the problem was resolved...

That pic was nasty as hell man.


All times are GMT -5. The time now is 7:32 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC