Explanation:
1. Creating a Tuple
a = (1, 2, 3)
This line creates a tuple named a.
A tuple is an ordered collection of elements.
Tuples are immutable, meaning their values cannot be changed after creation.
2. Trying to Modify a Tuple Element
a[0] = 10
This line tries to change the first element of the tuple (1) to 10.
Since tuples are immutable, Python does not allow item assignment.
This line causes an error.
3. Error Raised by Python
Python raises a:
TypeError: 'tuple' object does not support item assignment
Because of this error, the program stops executing at this line.
4. Print Statement Is Never Executed
print(a)
This line is never reached.
Once an error occurs, Python terminates the program unless the error is handled.
Final Output:
Error

0 Comments:
Post a Comment