July 2017
Beginner to intermediate
420 pages
10h 56m
English
x = [1, 2, 3, 4, 5, 6]print (len(x))
You can say, call a list x, for example, and assign it to the numbers 1 through 6, and these square brackets indicate that we are using a Python list, and those are immutable objects that I can actually add things to and rearrange as much as I want to. There's a built-in function for determining the length of the list called len, and if I type in len(x), that will give me back the number 6 because there are 6 numbers in my list.
Just to make sure, and again to drive home the point that this is actually running real code here, let's add another number in there, such as 4545. If you run this, you'll get 7 because now there are 7 numbers in that list:
x = [1, 2, 3, 4, 5, 6, 4545] ...
Read now
Unlock full access