Jump to content


Photo

Chapter 5 (p 167)


  • Please log in to reply
2 replies to this topic

#1 Andy_K_22206

Andy_K_22206

    New Member

  • Members
  • Pip
  • 3 posts

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'])

Edited by Andy_K_22206, 31 March 2014 - 01:16 PM.


#2 Andy_K_22206

Andy_K_22206

    New Member

  • Members
  • Pip
  • 3 posts

Posted 31 March 2014 - 01:28 PM

hmm.. weird.
now it works. even with red highlighted codes.

#3 Delabi

Delabi

    New Member

  • Members
  • Pip
  • 1 posts

Posted 26 July 2014 - 03:19 AM

So what did you do to make it work?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users