Question #913

What is the output of the code snippet below?
my_list = [None, None]
my_list[2:] = [True]

Another Python syntactic sugar! First, my_list[2:] accesses the list after the 2nd element, e.g. after the second None . Because my_list[2:] represents all elements between the second None and the end of the list, updating this area with another list will be equivalend to the append() method. (

Comment on Disqus:

Question difficulty: 🔵🔵🔵🔵🔵