Hey all,
I'm new to programming and seem to have an issue with the "time.sleep(900)" utility. Every time I put that command in my code, it will execute, despite that it is in a "if" conditional and the condition is not met. So, my code is:
import urllib.request
import time
def get_price():
page = urllib.request.urlopen("http://www.beans-r-us.biz/prices-loyalty.html")
text = page.read().decode("utf8")
where=text.find(">$")
start_of_price=where + 2
end_of_price=where + 6
return float(text[start_of_price:end_of_price])
print("Welcome!")
price_now = input("Is the price required immediately? (Y/N)")
if price_now == "Y":
print(get_price())
else:
price = 99.99
while price > 4.74:
price = get_price()
print(price)
time.sleep(30) <---------------This guy will slow the entire program even if the price retrieved is less than 4.74
print("Buy!")
I usually check the price manually to ensure the code is working, thus I know it is not. I would appreciate some help. Thanks!











