How to convert Int to string in Python?

Python is a popular user-friendly programming language. Python can be used in Game development, web apps, and even a desktop app because of python is multi-purpose and high-level programming language.

convert Int to string in Python

Some important use of Python is:

  • Python is used to create web apps.
  • In python we also create a desktop application.
  • handle complex data.
  • connects to database systems.
  • Used on a server


As we know integer is a number and converting Int (integer) into a string is used to easily align output into a table or an order lists. In python, there are few ways to convert Int into a string but in this tutorial, we use the str function to convert int into a string.

Open your python code editor like Pycharm

First, take a simple example, In this we do some simple math in python.

a = 79+55
s = str(a)
# Output comes 134

What going on this code. “a” is input and “s” is our output and str is a function which converts int into a string. In this code str(a) to take input and perform math and give a result to “s”.

Also read : How to set up local web server in python?

Take a second example

time = 5
print(“ Today I wake up at “ + str(time) + ” O’ clock in the morning.”)
# Output
# Today I wake up at 5 O’clock in the morning.

Explanation of this Python code

Time is an integer with a value 5

str(time) function converts “time” integer value into string value.

If we remove the “str” function in this code after that python gives an error like this “TypeError: must be str, not int”.  

I've loved ❤ technology and always curious about new tech innovation. I've been a technology writer and passionate blogger for last 3 year and write How to guide to help people become a tech-savvy.

Leave a Comment