[Tutor] doubt in a program

vinod bhaskaran bhaskaran.vinod at gmail.com
Mon Jan 29 01:42:57 EST 2018


Hi,

I am a new beginner in programming.
I saw a code (given below) to reverse  string.

newstring = ''
oldstring = 'Newton'
for char in oldstring:
   newstring = char + newstring
print(newstring)



Could someone explain how it is traversing to get the string reversed?

As the new character is adding the char in the new string but how is it
getting reversed without any line giving the char number to be traversed in
reverse order.

Thanks,
Vinod


More information about the Tutor mailing list