Python - How to convert integer to string

By xngo on June 7, 2019

#!/usr/bin/python3
# Description: How to convert integer to string.
 
int_var = 6
 
# Convert integer to string using str() function.
string_var = str(int_var)
 
print("Type of int_var    is {}".format(type(int_var   )))
print("Type of string_var is {}".format(type(string_var)))

Output

Type of int_var    is <class 'int'>
Type of string_var is <class 'str'>

About the author

Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.