Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (47.6k points)
edited by

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

d = 15 

d.str()

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 (106k 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) 

'10' 

>>> int('10') 

10

Related questions

Browse Categories

...