This shows you the differences between two versions of the page.
niftypythoncommands [2012/03/09 10:43] |
niftypythoncommands [2012/03/09 10:43] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | |||
+ | Getting the contents of a list in reverse order. | ||
+ | |||
+ | Say you have a list like this | ||
+ | |||
+ | areversedlist=" | ||
+ | |||
+ | And you'd actually like to get the contents from the end of the list this is how you could do it: | ||
+ | |||
+ | areversedlist.split(',' | ||
+ | |||
+ | The command above would give you the contents of the list only from back to front | ||
+ | |||
+ | [' | ||
+ | |||
+ | This could come in quite handy if you have long lists and you don't want to manually split them up in order to reverse them. |