Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 20th, 2004, 10:40 AM   #1
mfo6463
Newbie
 
Join Date: Nov 2004
Posts: 10
Rep Power: 0 mfo6463 is on a distinguished road
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?
mfo6463 is offline   Reply With Quote
Old Nov 20th, 2004, 11:27 AM   #2
thechristelegacy
Expert Programmer
 
thechristelegacy's Avatar
 
Join Date: Jul 2004
Location: Somerset, Pa
Posts: 707
Rep Power: 4 thechristelegacy is on a distinguished road
Send a message via AIM to thechristelegacy Send a message via MSN to thechristelegacy
It's becuase the variable dec hasn't been defined (as far as I can see from your example, unless there is more code...?
thechristelegacy is offline   Reply With Quote
Old Nov 20th, 2004, 11:45 AM   #3
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 5 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
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...

__________________

tempest is offline   Reply With Quote
Old Nov 20th, 2004, 12:03 PM   #4
mfo6463
Newbie
 
Join Date: Nov 2004
Posts: 10
Rep Power: 0 mfo6463 is on a distinguished road
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
mfo6463 is offline   Reply With Quote
Old Nov 20th, 2004, 12:14 PM   #5
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 8 Ooble is on a distinguished road
Thanks for the lovely pic, Tempest...
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Nov 20th, 2004, 1:02 PM   #6
Beegie_B
Programmer
 
Join Date: Nov 2004
Location: Windsor, Ontario, Canada
Posts: 32
Rep Power: 0 Beegie_B is on a distinguished road
Send a message via ICQ to Beegie_B Send a message via MSN to Beegie_B
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
Beegie_B is offline   Reply With Quote
Old Nov 20th, 2004, 2:53 PM   #7
mfo6463
Newbie
 
Join Date: Nov 2004
Posts: 10
Rep Power: 0 mfo6463 is on a distinguished road
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.
mfo6463 is offline   Reply With Quote
Old Nov 20th, 2004, 8:01 PM   #8
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,453
Rep Power: 7 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
Glad the problem was resolved...

That pic was nasty as hell man.
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:01 AM.

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