My code below is not generalized; it handles each line of output as a special case. How I could get the same output using a while or for statement?
string = "Apple"
i = 0
one = string[0:i+1]
two = string[0:i+2]
three = string[0:i+3]
four = string[0:i+4]
five = string[0:i+5]
print(one)
print(two)
print(three)
print(four)
print(five)
I have the following result:
A
Ap
App
Appl
Apple