Skip to content

Latest commit

 

History

History
21 lines (14 loc) · 515 Bytes

python-builtin-notes.md

File metadata and controls

21 lines (14 loc) · 515 Bytes

Python Builting Notes

Len

The len function can be called with an number of types to provide their length.

print(len("Elliot")) #=> 5
print(len([1, 2])) #=> 2

Calling this method actually calls the __len__ method on the object. So the string example resolves to "Elliot".__len__() and the list example resolves to [1, 2].__len__().

Range

Range is an immutable sequence data type. It can be used to iterate over a range of numbers:

for i in range(1, 5):
    print(i)