Wednesday, March 3, 2021

Python Memo 1: Tuple vs. List

Tuple vs. List

Both Tuple and List can store mixed types of values.

Plain Text
 




x


 
1
a = [1,"Hello",bool(0)]
2
b = (1,"Hello",bool(0))
3
a, b
4
Out: ([1, 'Hello', False], (1, 'Hello', False))


Tuple is immutable and length is fixed. List is mutable and length is not fixed.



from DZone.com Feed https://ift.tt/3qjqfBv

No comments:

Post a Comment