-
What is Code?
-
Data
-
Input
-
Boolean logic and decisions
-
Loops
-
Modules
-
Examples
-
Exercises
Input Type
Sometimes, we want the user to enter a number. Here is an example:
If our input is 5, we expect the result to be 10, not 55!
The input() function returns a value that is a string type, but we want an integer.
We can't ask the input to returns numbers instead of strings, but we can convert the output of input from a string to a number.
We do this using a function called int().
It still doesn't work!
However, the error gives us a clue, we can't concatenate two values with different types.
To fix this we convert the integer to a string