More Needles in the Haystack
We'll cover the following...
We aren’t yet done with the tiny bits of information that Pythonists miss out on.
1.
The following code has an assert statement with an assertion failure message.
Press + to interact
a = "python"b = "javascript"assert(a == b, "Both languages are different")
No assertion was raised in the code. Why is that so?
2.
Let’s try to modify a dictionary.
Press + to interact
some_list = [1, 2, 3]some_dict = {"key_1": 1,"key_2": 2,"key_3": 3}some_list = some_list.append(4)some_dict = some_dict.update({"key_4": 4})# Let's check if the new values were addedprint(some_list)print(some_dict)