>>> tup=(1,"apple",["jim","sammy"])
>>> tup
(1, 'apple', ['jim', 'sammy'])
# Tuples is immutable / unchangeable
>>> tup[0]=1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'tuple' object does not support item assignment
#The list inside the tuple can be changed though!!
>>> tup[2][1]="tommy"
>>> tup
(1, 'apple', ['jim', 'tommy'])
>>> tup
(1, 'apple', ['jim', 'sammy'])
# Tuples is immutable / unchangeable
>>> tup[0]=1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'tuple' object does not support item assignment
#The list inside the tuple can be changed though!!
>>> tup[2][1]="tommy"
>>> tup
(1, 'apple', ['jim', 'tommy'])
No comments:
Post a Comment