How to Convert Int to String in Python

If you need to turn a whole number into text in Python, use str().

This is common when:

  • combining numbers with text
  • joining numbers into one string
  • writing numbers as text in messages or files

In Python:

  • an int is a whole number like 5 or 42
  • a string is text like "5" or "hello"

Quick answer

age = 25
text = str(age)

print(text)
print(type(text))

Output:

25
<class 'str'>

Use str() when you need a string version of an integer.

When to convert an int to a string

Convert an integer to a string when you want to use the number as text.

Common cases:

  • combining a number with words
  • joining values into a larger string
  • writing numbers as text to a file, message, or label

For example, 25 is a number, but "25" is text.

That difference matters because Python treats numbers and text as different types.

Main way: use str()

The main way to convert an integer to a string is str(number).

number = 42
text = str(number)

print(text)
print(type(text))

Output:

42
<class 'str'>

Here:

  • number is still an integer
  • text is a new string

str() does not change the original value unless you save the result.

number = 42
str(number)

print(number)
print(type(number))

Output:

42
<class 'int'>

If you want to keep the converted value, assign it to a variable.

If you want to understand this function in more detail, see the str() function explained.

Combine an integer with text safely

A very common beginner mistake is trying to add text and a number with +.

This causes an error:

print("Age: " + 25)

Python raises a TypeError because "Age: " is a string and 25 is an integer.

Use str() first:

print("Age: " + str(25))

Output:

Age: 25

This works because both parts are now strings.

If you are seeing this exact error, read how to fix TypeError: can only concatenate str (not "int") to str.

Use f-strings as an easier option

When you are building a larger string, an f-string is often easier.

age = 25
print(f"Age: {age}")

Output:

Age: 25

Inside the braces, Python converts the value automatically.

This is often simpler than writing:

age = 25
print("Age: " + str(age))

Use:

  • str() when you want a direct conversion
  • an f-string when you are building text with variables

If you want more formatting examples, see how to format strings in Python and Python strings explained.

Convert multiple integers in a list

Another common problem happens with join().

join() only works with strings, not integers.

This will fail:

numbers = [1, 2, 3]
result = ", ".join(numbers)

print(result)

You need to convert each integer first.

A simple way is map(str, numbers):

numbers = [1, 2, 3]
result = ", ".join(map(str, numbers))

print(result)

Output:

1, 2, 3

What this does:

  • str converts each number to text
  • map(str, numbers) applies that conversion to every item
  • join() combines the strings with ", " between them

Common mistakes

Here are the most common problems beginners run into:

  • forgetting to convert before using + with text
  • thinking print() changes the type of a value
  • trying to use join() on integers directly
  • confusing str() conversion with string formatting

1. Trying to add a string and an integer

This fails:

message = "Score: " + 100

Fix it like this:

message = "Score: " + str(100)
print(message)

2. Using join() on a list of integers

This fails because the items are not strings:

numbers = [4, 5, 6]
# ", ".join(numbers)

Fix it like this:

numbers = [4, 5, 6]
text = ", ".join(map(str, numbers))
print(text)

3. Assuming printed output means the value is already a string

This can be confusing:

value = 7
print(value)

It prints 7, but the value is still an integer.

Check the type to be sure:

value = 7
print(type(value))

Output:

<class 'int'>

4. Not saving the result of str()

This does not change value:

value = 9
str(value)

print(type(value))

If you need the string later, save it:

value = 9
text = str(value)

print(type(text))

Useful checks while debugging

If you are not sure whether a value is an integer or a string, these quick checks help:

value = 25

print(value)
print(type(value))
print(str(value))
print(type(str(value)))

Output:

25
<class 'int'>
25
<class 'str'>

This is useful when debugging code that mixes numbers and text.

FAQ

How do I convert an int to a string in Python?

Use str(number). For example, str(10) returns "10".

Does str() change the original integer?

No. It returns a new string value. Save it if you want to use it later.

Why do I get an error when I do "hello" + 5?

Because Python cannot directly add text and an integer. Convert the integer first with str(5).

Should I use str() or an f-string?

Use str() for direct conversion. Use an f-string when building a larger string with variables.

How do I join a list of integers into one string?

Convert each item first, such as ", ".join(map(str, numbers)).

See also