

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
Not enough gems
Cost: 6 gems
1: Python Numbers
incomplete
2: Numbers Review
incomplete
3: Floor Division
incomplete
4: Exponents
incomplete
5: Changing in Place
incomplete
6: Plus Equals
incomplete
7: Scientific Notation
incomplete
8: Logical Operators
incomplete
9: Not
incomplete
10: Binary Numbers
incomplete
11: Bitwise '&' Operator
incomplete
12: Bitwise '|' Operator
incomplete
13: Damage Meter
incomplete
14: Converting Binary
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Python makes reassignment easy when doing math. In JavaScript or Go, you might be familiar with the ++ syntax for incrementing a number variable by 1. In Python, we use the += in-place operator instead.
star_rating = 4
star_rating += 1
# star_rating is now 5
The other in-place operators work similarly:
star_rating = 4
star_rating -= 1
# star_rating is now 3
star_rating = 4
star_rating *= 2
# star_rating is now 8
star_rating = 4
star_rating /= 2
# star_rating is now 2.0
Complete the get_hurt function. It should use the -= in-place operator to subtract damage from current_health and then return the new current_health.
You cannot use -= in a return statement. Set the variable first, and then return it after!