Jump to content


Photo

"while" Loop Seems To Be Frozen - P. 72 Exercise


  • Please log in to reply
1 reply to this topic

#1 JMurr

JMurr

    New Member

  • Members
  • Pip
  • 1 posts

Posted 03 October 2012 - 10:41 AM

Hi,

I seem to be stuck on the "While" loop in Chapter 2 - page 72. The odd thing is that I had done this exercise previously a few weeks ago and everything worked fine. I went back to "practice" and re-do some of the exercises but now I'm getting different results, or in this case no result. Very confused as I am new to programming (hence my purchase of this book!) To my knowledge, nothing has changed on my PC.

Please Help !!! I am using Python 3.2 on a Windows XP OS.

Thanks,
John
******************************************************************
Here is the relevant code and shell when I run it :

import urllib.request
import time

price = 99.99
while price > 4.50:
page = urllib.request.urlopen("http://beans-r-us.bi...iz/prices.html")
text = page.read().decode("utf8")

where=text.find('>$')
pricebeg = where+2
priceend = pricebeg + 4
price = float(text[pricebeg:priceend])
time.sleep(60)

print ("BUY Smartypants!")


After saving the code and hitting F5 to run it, this is the shell (i.e. nothing):

Python 3.2.3 (default, Apr 11 2012, 07:15:24) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>>

>>> ================================ RESTART ================================
>>>

#2 #TM#

#TM#

    Active Member

  • Members
  • PipPipPip
  • 76 posts
  • Gender:Not Telling

Posted 11 December 2012 - 04:29 AM

may be indentation is not proper check it out !!

and u have to wait for 60 secs also .

Edited by #TM#, 11 December 2012 - 04:48 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users