6️⃣

19.6 Wrapping Up

Wrapping Up

In this lesson, you learned:
  • How to use the try/except clause in your Python code
  • Whether or not to use specific exceptions
  • How to use the else and finally keywords
  • How to use the assert keyword for debugging

Practice

List Practice

Write a function that accesses a global list. It should try to take the user’s input for how many times to repeat its process. Its process should be:
1. Ask the user for a value (any type)
2. Append that value to the list.
Once that is done, ask the user to press q to quit or to input a number to access that index of the list. There should be a different error message depending on the type of error raised. Whether or not there are errors, when the user is done (or there is an error), it should print the list and ask the user whether they would like to continue. If this input is ‘y’, call the function again.
Demo video:
Video preview

Previous Section

5️⃣
19.5 Finally

Next Section

Ch. 19 Quiz
 
⚖️
Copyright © 2021 Code 4 Tomorrow. All rights reserved. The code in this course is licensed under the MIT License. If you would like to use content from any of our courses, you must obtain our explicit written permission and provide credit. Please contact classes@code4tomorrow.org for inquiries.