Thursday, August 1, 2019

Python Program | Convert int to str in Python

str() is a built-in function used to convert integer to string in python. By converting numbers into strings you can avoid "TypeErrors".

str() built-in function can be used to convert integer object into string in python. 
Since Python does not implicitly typecast floats and integers to strings.

Syntax

str(object, encoding=encoding, errors=errors)


Returns

str() function converts integer and float literals into string. String literals are denoted by single or double quotation marks.

Example: "Hello World" and 'Hello World' is same

Let's look at an example:

str(45)
str(88.8)
'blue' + str(45)



Output
'45'
'88.8'
'blue45'

Note: You can use three double quotes to assign a multiline string.

Related Posts:

If You Enjoyed This, Take 5 Seconds To Share It