Hello World!

Step 6 – Adding to the age

So, let's tell the user how old they will be at their next birthday.

That should be easy. All we need to do is add one to the userAge variable.

Code helper image
  1. To add one to the age we use:  userAge = userAge + 1
  2. Then print their new age out:  print("At your next birthday you will be", userAge)
  3. Now run the program

This won't work! (that's OK, it's not supposed to!)

You probably got an error message like this:

Code helper image

We'll fix this in the next step.

THEORY: all we're trying to do here is get the value that's stored in UserAge, add one to it, and then store it back in userAge. This is a really common way to change the value of a variable that's a number.