0
can we use string type data in python's while loop?can anyone give me example?
4 Respostas
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.....
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)
0
THANKS FRIENDS
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