Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
The print function
Variables
9. Assigning new values to variables
Math in Python
The input function
Summary

Instruction

Great! You can change the values of variables at any moment. Take a look:

current_age = 25
print(current_age)
current_age = 26
print(current_age)

The code above will print 25 and then 26. If you want a new value for your variable, simply use the equals operator (=) again.

Exercise

  • Create a variable named mood with a string value: I feel good today.
  • Print the value of mood.
  • Assign a new value to mood: I feel bad today.
  • Print the mood variable again.

Stuck? Here's a hint!

You will need four lines of code. Remember that string values must be surrounded with either single or double quotation marks:

mood = 'I feel good today'