This while loop prints each letter of the word 'banana' on a separate line.
Thu Sep 22 2022 00:54:08 GMT+0000 (UTC)
Saved by @L0uJ1rky45M #python
This pattern of processing is called a traversal where the program starts at the beginning, selects each character in turn, does something to it, and continues until the end. The loop condition is index < len(fruit). When index == length of the string, the condition is false, and the body of the loop is not executed. The last character accessed is the one with the index len(fruit)-1, which is the last character in the string.
https://www.py4e.com/html3/06-strings
Comments