O'Reilly Forums: "while" Loop Seems To Be Frozen - P. 72 Exercise - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

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

#1 User is offline   JMurr 

  • New Member
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 03-October 12

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.biz/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 ================================
>>>
0

#2 User is offline   #TM# 

  • Active Member
  • PipPipPip
  • Group: Members
  • Posts: 60
  • Joined: 10-December 12
  • 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 .

This post has been edited by #TM#: 11 December 2012 - 04:48 AM

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users