Creating an Array: Difference between revisions
Content deleted Content added
list methods are not related to creating lists |
|||
Line 348:
List are mutable arrays. You can put anything into a list, including other lists.
empty = []
numbers = [1, 2, 3, 4, 5]
Line 355 ⟶ 356:
evens = range(0,10,2) # Optional arguments to range() can specify start, stop, and step
squares = [ x * x for x in range(100) ] # List comprehension expressions can create lists
Tuples are immutable arrays. Note hat tuples are defined by the "," - the parenthesis are optional:
|