The quiz where the difficulty automagically adapts to the player's Python knowledge
This is a question page. You can use this page to bookmark a question. Start a new quiz!
Question #297
def f(x):
x.append(0)
return x
my_list = []
f(my_list)
print(my_list)
Python functions have side effects! As lists are mutable, 0 will be appended to my_list will every time the function is called. (docs.python.org/2/faq/programming.html#what-are-the-rules...)
What is the output of the code snippet below?
— The Python Quiz (@thepythonquiz) April 17, 2021
def f(x):
x.append(0)
return x
my_list = []
f(my_list)
print(my_list)
[]
[0]
π Comment the answer, like and retweet! #python
Question difficulty: π΅π΅π΅π΅π΅