0

Ans is wombat but I don't know the working of. for i in range(len(first),0,-1): function please explain

first = "wombat" second = " " for i in range(len(first),0,-1): second = first[i-1] + second Print(second)

12th Feb 2019, 4:01 AM
Shaik Abeedh
Shaik Abeedh - avatar
1 Answer
+ 6
The for in loop here is like : for i in range (len (first),0,-1): Length of first is 6. Hence, the loop will iterate from 6 to 0. -1 is specifying that loop will go in descending order rather than ascending order. That's why it will go from 6 to 0 and not from 0 to 6. Jay Matthews has explained further part pretty well.
12th Feb 2019, 4:47 AM
Arushi Singhania
Arushi Singhania - avatar