+ 3
What would happen if the list was inside normal brackets instead of the square ones?
Brackets
5 Antworten
+ 3
List - ["bar"]
Tuple - ("bar")
A tuple is similar to a list, but is immutable. This means that a tuple cannot be modified as a list can - it will remain the same as it was when first created. However, a tuple uses less memory.
- Use lists when data will be modified.
- Use tuples when no data needs to be modified.
+ 3
I tried coding such but I received an error
+ 1
>>> a = (1, 2, 3, 4, 5, 6)
>>> type(a)
<class 'tuple'>
It's not a list actually.