+ 1
Why itâs not getting into for loop,plz help
s="malayalam" for i in range(len(s)-1,0): print(i)
6 Answers
+ 6
You missed the "step" argument in range. By default it is 1. So you need range(len(s)-1, 0, -1)
+ 4
range goes [start; stop)
The stop is not included 8n the sequence. To get 0, you would need to write:
range(len(s) - 1, -1, -1)
0
Thank you Lisa u made my day new to python ,even small things are getting complex Thanks again
0
Lisa why
for i in range(len(s)-1,0,-1)
Why does the loop doesnt consider zero it stops at 1
In Java
for(int i=8;i>=0;iâ) here it goes till 0 no issues why not in python
0
Other than using range can u please suggest a for loop in python as simple as in Java like this
for(int i=0;i<=10;i++)
Without using that range function and all