I thought tuples were immutable but it seems you can swap them, so I'm confused:
a,b = 5,8 print a # result 5 a,b = b,a print a # result 8, so they swapped # but if I test the type of a,b I get a tuple testit = a,b print type(testit) #comes out as a tuple print testit, # result is (8,5) # So how am I swapping elements of a tuple when a tuple is immutable? #t rying so change a tuple since I just did it testit[1] = 14 #program crashes - *TypeError: 'tuple' object does not support item assignment *so the tuple I just changed is indeed immutable -- Jim Mooney "Coding? You can get a woman to do that!" he said with a sneer. --heard from a physics professor in 1969
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor