O'Reilly Forums: Chapter 5 Tester Surf Code - O'Reilly Forums

Jump to content

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

Chapter 5 Tester Surf Code Not getting a response

#1 User is offline   Drew_54235 

  • New Member
  • Pip
  • Group: Members
  • Posts: 3
  • Joined: 24-January 14

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?

This post has been edited by Drew_54235: 31 January 2014 - 05:50 AM

0

#2 User is offline   Drew_54235 

  • New Member
  • Pip
  • Group: Members
  • Posts: 3
  • Joined: 24-January 14

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.
0

#3 User is offline   trul 

  • New Member
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 06-February 14

Posted 06 February 2014 - 02:23 AM

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

This post has been edited by trul: 06 February 2014 - 02:25 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