English subtitles

← Changing Lookup - Intro to Computer Science

Get Embed Code
4 Languages

Showing Revision 6 created 05/25/2016 by Udacity Robot.

  1. For the final quiz for this unit, your goal is to change the look up procedure
  2. to now work with dictionaries.
  3. Before we had look up working where index was a list of entries,
  4. and we did the look up by looping through the index, that required a lot of work
  5. we had to go through each entry, check if the keyword matched,
  6. and then return the one that matched, if we got to the end without finding it,
  7. we returned none.
  8. Your goal for the quiz, is to modify this code
  9. to now work where the index is going to be the dictionary,
  10. and we should be able to find the entry much more quickly.
  11. We don't need to loop through anything.
  12. we can use the property of the dictionary to look up the entry right away.
  13. If you understand the add to index code that we just did,
  14. I think you can define look up on your own.
  15. The one thing to be careful about,
  16. is that you need make sure that when the index does not contain the keyword,
  17. when it's not in the dictionary,
  18. instead of producing an error, that it returns the value none.