/* */

Tuesday 22 March 2011

List statement, assign to slices

name = list('Pearl')
name
['P','e','a,'r','l'']
name[2:] = list('ar')
name
['P','e','a','r']

List statement turned the string ('Pearl') into a list.
The list('ar') replaces anything from position 2 onwards in the name list, hence it's new value being ['P','e','a','r']

No comments:

Post a Comment