If tuples are immutable, so what is the benefit of creating an empty tuple ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

If tuples are immutable, so what is the benefit of creating an empty tuple ?

Immutable tuples

12th Apr 2019, 12:04 AM
Mohamed Ramadan
2 Answers
+ 3
When you need a container which is empty and immutable, like a constant which can be compared to, in order to check for emptiness, or an initial container which can be concatenated with other tuples (and even itself) to form new tuples. Trying doing this a = () n = int(input()) for i in range(0, n): a = a + (input(),) print(a) with input 3 this is working on Code Playground.
12th Apr 2019, 12:35 AM
Fermi
Fermi - avatar
0
The code is not working, having errors. can you review it please? Thanks in advance :)
12th Apr 2019, 8:59 AM
Mohamed Ramadan