Value of b

Report a typo

Lists, unlike strings, are mutable. We can use that to modify their data with indices.

Here's a simple piece of code. What will be the value of b after each line of code?

a = [1, 2, 3]
b = a
# what is the value of b?

a[1] = 10
# and here?

b[0] = 20
# what about now?

a = [5, 6]
# it is the last time, we promise. The value of b?

Please, enter the values in a single line. Separate the list elements with space and the lists — with a semicolon. For example:

1 1 1; 2 2 2; 3 3 3; 4 4 4

Since b = a, they refer to the same object.
Enter a short text
___

Create a free account to access the full topic