Covert Number to string? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

Covert Number to string?

How can i convert numbers to strings in python

7th Nov 2018, 11:21 AM
Mensch
Mensch - avatar
5 Answers
+ 19
Just use the built-in str() function. So str(142) is "142"
7th Nov 2018, 11:24 AM
Kishalaya Saha
Kishalaya Saha - avatar
+ 3
num=123 #convert 123 to string str(num) >> '123' nuM='1234' #convert '1234' to number int(nuM) >> 1234
7th Nov 2018, 11:30 PM
FitBug
FitBug - avatar
+ 3
You can use for example: str(112) to convert an number to a string...
8th Nov 2018, 3:18 PM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar
+ 2
num = 1337 str(num) >> "1337" #convering and checking the type num = str(num) type(num) >> str
7th Nov 2018, 3:28 PM
Willkizy
Willkizy - avatar
+ 2
It's easy just use the str function. For example: str(123) = "123" You can, in the same way use, the int, list, float etc function to convert the object into a integer, list, float etc...
8th Nov 2018, 5:08 AM
Kunal Mishra
Kunal Mishra - avatar