Search⌘ K
AI Features

This is the End

Discover key Python quirks including how out-of-bounds list slicing behaves, string counting with empty substrings, numeric literals with underscores, and handling of different digit characters. Learn to navigate these details to write clearer Python code and avoid common pitfalls.

We'll cover the following...

1.

List slicing with out of bounds indices throws no errors.

Python 3.5
some_list = [1, 2, 3, 4, 5]
print(some_list[111:])

2.

Slicing an iterable does not always create a new object. For example:

Python 3.5
some_str = "ftwpython"
some_list = ['f', 't', 'w', 'p', 'y', 't', 'h', 'o', 'n']
print(some_list is some_list[:]) # False expected because a new object is created.
print(some_str is some_str[:]) # True because strings are immutable, so making a new object is of not much use.

3.

...