2009/9/24 ALAN GAULD <alan.ga...@btinternet.com>: >> print message[::-1] > > Yes, the for loop doing one character at a time will be much > slower than using a slice. The slice is more pythonic but less general. > A reverse loop is something that is often needed in programming > solutions so it's useful to know how to do it for the general case.
I have seen this some times but never really understood how it worked. I have 1 thing I am not sure of, the negative slice in the example basically means "start counting at the end position and work backwards"? Does anyone have an advanced topic on slicing where the :: notation is explained? Thanks Sander _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor