3 ms·
I think only the second is truly bug-free. The first only does what the user expects if they pass in a non-empty list: my_list = [] append_one(my_list) #
by calvins 12y ago
I think only the second is truly bug-free. The first only does what the user expects if they pass in a non-empty list:
my_list = []
append_one(my_list)
# my_list didn't get anything appended to it
This shows up another subtle trap related to the "truthiness" (or falsiness in this case) of things like the empty list.