OneBite.Dev - Coding blog in a bite size

convert variable from int to string in python

Code snippet on how to convert variable from int to string in python

num = 100
str = str(num)

This code snippet demonstrates how to convert an integer (int) to a string. The first line assigns the value 100 to the variable num. The second line converts num to a string and assigns it to the variable str. The function str() takes an object (in this case an integer) and returns a string object. This code would result in the str variable holding the value ‘100’.

python