Please, consider if this is pertinent to this forum about Jupyter? If you ran this Python code in a more traditional way, such as in the console or as the content a script you called from the command line for Python run, would it give the same outcome? (If you are new to running Python code, you may not be able to do this exercise in your mind, and should actually step through the exercise.) If so, it isn’t a Jupyter issue and so not pertinent to this forum. You’ll want to seek help in a pertinent location.
Your provided code is unuseable and nearly unreadable.
For pasting code in so it is readable in forums such as this & useable by those you want to help you, you’ll want to learn about ‘block code formatting’ here. (Or see about ‘fenced code blocks’ here. They are both the same thing if you look into the details. They just have slightly different terms used in the two locations.