Skip to content
Foxipa
Code Completion 4 Challenges

Complete the Python Augmented Assignment Code

Practice updating names, mutable objects, attributes, and indexed values with augmented assignment.

Core ~10 min read

Challenge 1

Add 2 to count using augmented assignment.

python Your answer
count = 3
count  2
print(count)

Press Ctrl⌘Enter to check your answer

Challenge 2

Extend values in place with the two new numbers 3 and 4.

python Your answer
values = [1, 2]
values 
print(values)

Press Ctrl⌘Enter to check your answer

Challenge 3

Increase basket.count by 5 using augmented assignment.

python Your answer
class Basket:
    def __init__(self, count):
        self.count = count

basket = Basket(2)
basket.count  5
print(basket.count)

Press Ctrl⌘Enter to check your answer

Challenge 4

Subtract 3 from the second list item using augmented assignment.

python Your answer
items = [10, 8, 6]
items[1]  3
print(items)

Press Ctrl⌘Enter to check your answer