0

can we use string type data in python's while loop?can anyone give me example?

4th Apr 2020, 1:42 PM
HAMZA
4 Answers
0
string="" i=1 while i <=5: string=input() print(string) i+=1 print("Finished!") Takes 5 input of strings and prints.. How you want to use...? There is no restriction to while loop, related to string or any loops.. You can use it as you use it without loops.....
4th Apr 2020, 1:50 PM
Jayakrishna 🇼🇳
0
you can do this: i=0 string ="this is a string" while i<len(string) : #do something print(string[i]) i+=1 but it's better to use the for loop : for l in string: #do something print(l)
4th Apr 2020, 2:13 PM
John Robotane
John Robotane - avatar
0
THANKS FRIENDS
4th Apr 2020, 2:31 PM
HAMZA
0
You even could do: s = "forty-two" while s: print(s[0]) s = s[1:] # output: f o r t y - t w o
4th Apr 2020, 6:28 PM
visph
visph - avatar