0 votes
1 view
in Python by (31.4k points)
edited by

I want to convert an integer to a string in Python. I am typecasting it in vain:

d = 15 


When I try to convert it to a string, it's showing an error like int doesn't have any attribute called str.

1 Answer

0 votes
by (73.5k points)

In, Python the conversion to a string is done with the built-in str() function, which basically calls the __str__() method of its parameter. See the code below:-

>>> str(10) 


>>> int('10')