How to convert int to string in Python

In python, int can be converted to a string using the str() function. This is a built-in function similar to int(). The str() function takes an int type data as its parameter and convert it into string datatype.
This conversion is possible through other methods also like using fstring funtcion, using “%s” keyword, the .format() function.
1. str()
input=10 #input of the form int out=str(input) #converting to string print(out) #print the converted string
2. fstring function
input=10 out=f'{input}' print(type(out)) #print the type
3. “%s” keyword
input=10 print("% s" % input)
4. .format() function
input=10 '{}'.format(input)
Subscribe
Login
Please login to comment
0 Discussion