$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · easy · #57

What is the correct fix?

a = [1, 2, 3]
b = a
b.append(4)
print(len(a))
  1. Copy it with b = a[:] instead
  2. Copy it with b = a[0] instead
  3. Change b.append(4) to b + [4]
  4. Declare b before a is created
b = a binds the same list, so appending is visible through a; slice to copy it.
Play Problem Solving ▸