Today our builtin function is str() which is useful for converting any datatype in to a string. This is very much useful to convert one datatype to a string.

Need of str() function in Python:

Some times in programming when we try to club two datatypes it may give you TypeError like "TypeError: cannot concatenate ‘str’ and ‘int’ objects". In that case we can convert those data types in to strings and do manuplation and convert them back to desired data types. In this post we will see on how to use str() python built-in function.

str() function syntax:

Examples: Let us start with str() function with some examples and see how we can use them in Python coding.
Example1: Convert a number into a string .
>>> str(‘23’)
Example2: Adding a string which is number to other number

My variables are



Adding two numbers in which one is in string formats.





If you observe it concatenated two numbers instead of adding them. 
Related functions: chr(), str(), ord(), int()