Re: [Tutor] doubt in a program

2018-01-29 Thread Jan Erik Moström
On 29 Jan 2018, at 7:42, vinod bhaskaran wrote: 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. You don't need that, think about this example newstring = '' oldstring = "Newton

Re: [Tutor] doubt in a program

2018-01-29 Thread vinod bhaskaran
Thanks a lot Nitin. I misunderstood the "char + newstring". As a newbie to programming as well as newbie to Python trying to grasp basics. Sure will need the built in functions present for different things in Python. Any suggestion good book for python? Thanks, Vinod Bhaskaran On Mon, Jan 29, 201

Re: [Tutor] doubt in a program

2018-01-29 Thread Nitin Madhok
Vinod, First time it loops, newstring = ‘’ oldstring = ‘Newton’ char = ‘N’ char + newstring = ‘N’ + ‘’ = ‘N’ Second time it loops, newstring = ‘N’ oldstring = ‘Newton’ char = ‘e’ char + newstring = ‘e’ +’N’ = ‘eN’ Third time it loops, newstring = ‘eN’ oldstring = ‘Newton’ char = ‘w’ char + news

Re: [Tutor] doubt in a program

2018-01-29 Thread Alan Gauld via Tutor
On 29/01/18 06:42, vinod bhaskaran wrote: > newstring = '' > oldstring = 'Newton' > for char in oldstring: >newstring = char + newstring > print(newstring) > > Could someone explain how it is traversing to get the string reversed? print statements are your friend. Add print statements everyw