Assuming that the tuple is a correctly created tuple,

Assuming that the tuple is a correctly created tuple,

the fact that tuples are immutable means that the following instruction:

my_tuple[1] = my_tuple[1] + my_tuple[0]
A . can be executed if and only if the tuple contains at least two elements
B. is illegal
C. may be illegal if the tuple contains strings
D. is fully correct

Answer: B

Explanation:

Topics: dictionary

Try it yourself:

my_tuple = (1, 2, 3)

my_tuple[1] = my_tuple[1] + my_tuple[0]

# TypeError: ‘tuple’ object does not support item assignment

A tuple is immutable and therefore you cannot

assign a new value to one of its indexes.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments