Code:
def money(coinPrice):
import urllib
connection = urllib.urlopen("http://www.usagold.com/gold/price.html")
rate = connection.read()
connection.close()
currentLoc = rate.find("> coinPrice </A></div>")
if currentLoc != -1:
rateLocEnd = rate.rfind('</TD>', 0, currentLoc)
rateLocStart = rate.rfind('<TD width = "50">', 0, rateLocEnd)
rateCloseGold = rate[rateLocStart+4:rateLocEnd]
print "The price of", coinPrice, "Gold in US$ is", rateCloseGold
here is what I have, and the goal is to print out a statement that shows the closing price of gold in us dollars, by inputing what kind of gold you would like as an argument. I am not sure why this is ont working for me, it prints out much more than the 1 line in my print statement and I have copied a program that works properlly, but this one does not, I am guessing it has something to do with the fact that this one takes an argument. please help.
Comment