🤯 Tuple or List? Can you guess the output? #pythoncoding #coding

preview_player
Показать описание
🤯 Tuple or List? Can you guess the output?

💡 Hint: Tuples are immutable, but are lists inside them? 🤯

#Python #CodingChallenge #PythonQuiz #LearnPython #ProgrammingFunPython, Python quiz, Python interview question, Python coding challenge, Tuple vs List, Mutable vs Immutable, Python tricks, Learn Python, Python for beginners, Python programming, Debugging Python, Python coding fun
Рекомендации по теме
Комментарии
Автор

1. x is a tuple containing two lists: ([1, 2], [3, 4]).


2. x[0] refers to the first list [1, 2].


3. x[0].append(5) modifies this list in-place, so it becomes [1, 2, 5].


4. Since tuples are immutable, you cannot reassign x[0] = something_else, but you can modify the contents of mutable objects (like lists) inside the tuple.


5. The final value of x is:

([1, 2, 5], [3, 4])

srividhyasrividhya