I am learning a coding language for the first time and that is Python. During my attempt to solve an online coding exercise I got a partially successful output - I got the results correct, but I also got an error message that I want to avoid. Pl. see the attached pic.:
Please do not post code in screenshots. Paste the actual code using proper formatting instead.
Your loop condition is while i <= len(List1), meaning the loop will run if i is exactly equal to len(List1). Consider the case were List1 contains only one element, i.e. its length is 1. Will List1[1] work?