Convert Integer number to String in Python

In this Python examples series of Python Basics tutorial for beginners, we will study and learn how to convert integer number to String in Python.

Use of str() function

In Python, any integer can be converted to String with str() function.

 

Syntax of str()

str(value)

 

  • str() is function name.
  • value is integer who need to be converted into Python String.

 

Examples of Integer to String conversions:

Let’s see how we can convert integer to String in Python by taking an example.

 

number=5
print(number)
print("number is of type: ",type(number))

print("*******")

str1=str(number)
print(str1)
print("str1 is of type: ",type(str1))

 

Output

5
number is of type: <class 'int'>
*******
5
str1 is of type: <class 'str'>

 

Explanation:

  • we have number variable whose value is 5.
  • we can check the type of number variable using type function in Python.
  • data type of number variable is integer.
  • Now we will use str() function to convert integer to String in Python.
  • After applying str() function and storing the result into new variable str1, we can check the data type of variable str1, which is String.
  • Hence, we successfully converted Integer number to String in Python
Please follow and like us:
READ  Write a program to check Prime number in Python

One Comment to “Convert Integer number to String in Python”

  1. […] our Python Examples series of Python basics tutorials online, we learnt how to convert Integer to String in Python, In this post of Python programming tutorial, we will study that how we can convert String to […]

Comments are closed.