Creating an Array: Difference between revisions

Content added Content deleted
(Lists with other lists)
(tuples)
Line 347:
[[Category:Python]]
 
List are mutable arrays. You can put anything into a list, including other lists:.
empty = []
numbers = [1, 2, 3, 4, 5]
zeros = [0] * 10
 
You can put anything into a list, including other lists:
anything = [1, 'foo', 2.57, None, zeros]
 
Tuples are immutable arrays. Note hat tuples are defined by the "," - the parenthesis are optional:
empty = ()
numbers = (1, 2, 3, 4, 5)
zeros = (0,) * 10
anything = (1, 'foo', 2.57, None, zeros)
 
==[[Toka]]==