On Mon, Jan 03, 2011 at 08:32:18PM +0530, Shrivats wrote: > On Mon, Jan 03, 2011 at 10:52:26PM +0800, Neo Vector wrote: > > Hi All, > Hello, > > Could you explain me how does it work, pls? > > Sure, I'm not telling you how that works. However, I'll alter your code > snippet > a little bit and see if you can understand after that. > > ============================== > > >>>r = '1' > > >>>for c in 'abcd': > print r > > r = c + r > > ... > > ... > 1 > a1 > ba1 > cba1 > > >>>r > > 'dcba1' > > ============================== > > Let me know if you still face problems. Oh, and for more information - http://docs.python.org/tutorial/introduction.html#strings http://docs.python.org/tutorial/controlflow.html#for-statements
Specifically, the idea behind this is, Strings are basically a list of characters. So they can be treated as iterable collections. :) > > HTH, > > Shrivats _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor