Page 202 -
P. 202
hashes and databases
Ready Bake
Code Here‛s some tester code that we‛ve cooked up especially
for you. This code will let you test your function:
Ask the user for the
surfer ID to find. lookup_id = int(input("Enter the id of the surfer: ")) Do this!
Call “find_details()” surfer = find_details(lookup_id)
on the entered surfer ID. if surfer:
print("ID: " + surfer['id'])
If data was found, print("Name: " + surfer['name']) Type this tester code,
display the nicely print("Country: " + surfer['country']) together with your
formatted messages. print("Average: " + surfer['average']) function, into IDLE. Be
sure to put the function
print("Board type: " + surfer['board'])
near the top of you file,
print("Age: " + surfer['age']) so that this tester code
appears after it.
Test Drive
Make sure the tester code and your function are entered into IDLE and saved
to a file as a new program. Press F5 to test your function.
Enter an existing surfer
ID and the program
displays the details.
Enter a nonexistent
surfer ID and the
program displays
nothing (as there's
nothing to display).
Great work! Your function is working well. Wonder how the RSA
folks feel about it?
you are here 4 167