Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Python by (16.4k points)

When I tried to convert an integer to a string,

d = 15

d.str()

I got an error saying like 

int doesn't have any attribute called str

Anyone, please guide me.

1 Answer

0 votes
by (26.4k points)

You can use str() for conversion to a string, which calls the __str__() method with its parameter.

>>> str(10)

'10'

>>> int('10')

10

Are you interested to learn python in detail? Join python certification course fast

Related questions

+3 votes
2 answers
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Sep 17, 2019 in Python by Sammy (47.6k points)

Browse Categories

...