1

I'm learning, so go easy on me.

What am I doing wrong here:

#!/usr/bin/python3.1

import urllib.request

page = urllib.request.urlopen ("http://au.finance.yahoo.com/q?s=AUDUSD=X")
text = page.read().decode("utf8")

where = text.find('Last Trade:</th><td class="yfnc_tabledata1"><big><b><span id="yfs_l10_audusd=x">')

start_of_us_price = where + 80
end_of_us_price = start_of_us_price + 6

us_price = text[start_of_us_price:end_of_us_price]

where = text.find('Trade Time:</th><td class="yfnc_tabledata1"><span id="yfs_t10_audusd=x">')

start_of_trade_time = where + 72
end_of_trade_time = start_of_trade_time + 11

trade_time = text[start_of_trade_time:end_of_trade_time]

print ('The price is $ 'us_price' as of 'trade_time'")
1
  • 2
    what exactly is the error? and you have a problem here in the last line - print i think you mean: print "The price is $", us_price, "as of", trade_time Commented Jan 10, 2011 at 9:09

1 Answer 1

4

The last line should be:

print ('The price is $ ', us_price, ' as of ', trade_time)

Consider this to understand it better:

>>> x = 3
>>> print('The value of x is:', 3, 'Yes!')
The value of x is: 3 Yes!
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.