0 votes
1 view
in Python by (47.8k 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 (107k 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

0 votes
1 answer
asked Oct 10, 2019 in Python by Sammy (47.8k points)
0 votes
1 answer
asked Sep 27, 2019 in Python by Sammy (47.8k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...