Post

Python Developer
Python Developer@PythonDvz·
🤔🚀 Comment your answers below! 👇
Python Developer tweet media
English
20
8
101
7.5K
Sergei Kotov
Sergei Kotov@kotov_dev·
Answer: B) Error The immutability trap! › a = tuple(a) converts list to tuple (1, 2, 3) › a[0] = 2 tries to modify the tuple › TypeError: tuples are immutable and can't be changed › Line 3 never runs, so no print For beginners: Tuples can't be modified after creation. Use lists when you need to change elements!
English
2
0
14
512
Earnest Codes
Earnest Codes@Earnesto037·
@Python_Dv Answer: B). Error The provided Python code will result in a TypeError because it attempts to modify an immutable object. The first line, a = [1, 2, 3], creates a list. Lists are mutable, which means their elements can be changed, added, or removed. The second line, a = tuple(a),
English
1
0
6
387
Omo Yewa
Omo Yewa@AceKelm·
@Python_Dv B. Error. Tuple are immutable. Meaning you can not change elements of tuple data type.
English
0
0
1
169
Rishu
Rishu@rishu29594130·
@Python_Dv Tuple is immutable So answer will be b
English
0
0
0
40
Ece
Ece@eceecobn·
@Python_Dv It gives an error because tuples are immutable
English
0
0
0
186
hop07
hop07@hop07·
@Python_Dv The output with Python 3.14.0 is: Traceback (most recent call last): File "/home/toshi/wk/python/scratch/test_tuple.py", line 5, in <module> a[0] = 2 ~^^^ TypeError: 'tuple' object does not support item assignment
English
0
0
0
85
Paylaş