Jump to content


Photo

Chapter 5 Tester Surf Code


  • Please log in to reply
2 replies to this topic

#1 Drew_54235

Drew_54235

    New Member

  • Members
  • Pip
  • 3 posts

Posted 31 January 2014 - 05:48 AM

Here is my code:
def find_details(id2find):
surfers_f= open("surfing_data.csv")
for each_line in surfers_f:
s={}
(s['id'], s['name'], s['country'], s['average'], s['board'], s['age'])= each_line.split(";")
if id2find == int(s['id']):
surfers_f.close()
return(s)
surfers_f.close()
return ({})
lookup_id = int(input("Enter the id of the surfer: "))
surfer = find_details(lookup_id)
if surfer:
print("ID: " + s['id'])
print("Name: " + s['name'])
print("Country: " + s['country'])
print("Average: " + s['average'])
print("Board: " + s['board'])
print("Age: " + s['age'])

And this is the message I am getting when i try 101. But 102-107 are not working either, it doesnt return anything at all.
print("ID: " + s['id'])
NameError: name 's' is not defined

What am I missing?

Edited by Drew_54235, 31 January 2014 - 05:50 AM.


#2 Drew_54235

Drew_54235

    New Member

  • Members
  • Pip
  • 3 posts

Posted 31 January 2014 - 05:56 AM

Never mind I figured out what I did. In the print part I didn't forgot above that I defined "surfer" as the variable not s.

#3 trul

trul

    New Member

  • Members
  • Pip
  • 1 posts

Posted 06 February 2014 - 02:23 AM

Hi this is the niceinformation Massage Santa Clara this is very helpful.thanku

Edited by trul, 06 February 2014 - 02:25 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users