O'Reilly Forums: Chapter 5 (p 167) - O'Reilly Forums

Jump to content

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

Chapter 5 (p 167)

#1 User is offline   Andy_K_22206 

  • New Member
  • Pip
  • Group: Members
  • Posts: 3
  • Joined: 31-March 14

Posted 31 March 2014 - 01:15 PM

Hello there,

During working on page 166-167, I found out some lines, highlighted in red need to be omitted.
with those red highlighted codes, I can only run key 101. However, except 101, it doesn't show any result.

any comments for this one?

--------------------------------------------------------------------------------------------------------------
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: " + surfer['id'])
print("Name: " + surfer['name'])
print("Country: " + surfer['country'])
print("Average: " + surfer['average'])
print("Board Type : " + surfer['board'])
print("Age : " + surfer['age'])

This post has been edited by Andy_K_22206: 31 March 2014 - 01:16 PM

0

#2 User is offline   Andy_K_22206 

  • New Member
  • Pip
  • Group: Members
  • Posts: 3
  • Joined: 31-March 14

Posted 31 March 2014 - 01:28 PM

hmm.. weird.
now it works. even with red highlighted codes.
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