Skip to content
Fix Code Error

Converting integer to string in Python

March 13, 2021 by Code Error
Posted By: Anonymous

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 string, it’s showing an error like int doesn’t have any attribute called str.

Solution

>>> str(10)
'10'
>>> int('10')
10

Links to the documentation:

  • int()
  • str()

Conversion to a string is done with the builtin str() function, which basically calls the __str__() method of its parameter.

Answered By: Anonymous

Related Articles

  • After a little scroll, the sticky navbar just is not fixed…
  • Can't install via pip because of egg_info error
  • What is the difference between __str__ and __repr__?
  • error LNK2005: ✘✘✘ already defined in…
  • Checking if a variable is an integer in PHP
  • Change column type in pandas
  • Callback functions in C++
  • No function matches the given name and argument types
  • no match for ‘operator
  • How to print binary tree diagram?

Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.

Post navigation

Previous Post:

How do I undo ‘git add’ before commit?

Next Post:

How do I vertically center text with CSS?

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Get code errors & solutions at akashmittal.com
© 2022 Fix Code Error