Hello World!

Step 7 – Fixing the problem

The problem is to do with the way that Python handles variables.

Python always stores everything as words. Everything.

That means that it can't add one to the number you entered – it thinks that your age is actually a word called "13" rather than the number 13 (or whatever).

This is quite annoying, but there's an easy way to fix the problem.

THEORY: the technical name for a word in Python is a string. Everything you enter using input becomes a string. So we have to tell Python that we'd actually like it to treat it like a number thank you very much.

Try this first

What if we tell is to add "1" to the number the user entered?

Code helper image

That might work

  1. Try the code in the screenshot
  2. Run it and see what happens

Hmm, that doesn't work. Instead of adding 1 to the number, Python sticks a 1 on the end of it to make what we think of as a much bigger number.

The solution

Here's what we have to do.

Code helper image

To fix the problem:

  1. Add a line of code between the input line and where you add one to the age: userAge = int(userAge)
  2. Now run the program again

This should work because the new like turns the age into a number rather than a word.

Python should be happy with that.

THEORY: the int stands for integer. An integer is a whole number and is one of the types of number Python can deal with.