Ask Question
29 September, 12:39

A lot of computations involve processing a string one character at a time. Often they start

at the beginning, select each character in turn, do something to it, and continue until the

end. This pattern of processing is called a traversal. One way to write a traversal is with a

while loop:

index = 0

while index < len (fruit):

letter = fruit[index]

print (letter)

index = index + 1

+3
Answers (1)
  1. 29 September, 13:00
    0
    The last character in the string processed is "t".

    Explanation:

    The index start from 0 and the len (fruit) is 5.

    When index is 0 which is less than 5; "f" is printed

    When index is 1 which is less than 5; "r" is printed

    When index is 2 which is less than 5; "u" is printed

    When index is 3 which is less than 5; "i" is printed

    When index is 4 which is less than 5; "t" is printed

    When index is 5, the condition is false; so the loop content is not executed.

    Therefore, the last character traversed in the string "fruit" is "t".
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “A lot of computations involve processing a string one character at a time. Often they start at the beginning, select each character in ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers