I need help to make this code work

For best results, please read the pinned thread, and then make sure of the following:

  1. Edit the first post to make these changes (don’t make a new post).

  2. Post the necessary code with proper formatting (using what you learned from the pinned thread).

  3. Make sure (by trying it yourself before submitting the edit) that someone else can copy and paste the code out of the post, without adding or changing anything, run it, and see the exact problem, directly.

  4. Show a complete error message by copying and pasting it - starting from the line that says Traceback (most recent call last): all the way to the end - and formatting it the same way as the code (but in a separate block).