+ 2
Just want to ask is this while loop only for numerical values??? Can't we use alphabet??
3 Respuestas
+ 6
you can use alphabet, but it will definitely be converted to an integer which you won't see and the loop will be longer than you can imagine 😉😉😉
+ 2
*AsterisK*, what you describe is C behavior, isn't it?
Anant Mishra, you seem to be using Python. In Python you can use every expression that can be interpreted as bool.
The guiding principle is that everything that's not nothing is True.
For iterables that means that empty iterables turn out False, iterables with something in it as True.
Examples:
while(True) # runs till you break
arr = [1, 2, 3]
while(arr)
# means as long as arr is not empty.
stri = 'whatever'
while(stri)
# runs as long as str is referring to a string that is not empty.
+ 1
I did the same wasn't sure that's y took help
Thanks*AsterisK*