'Why python not returning it's value in double quotes when it is string [closed]
I have converted integer value to string although it is not returning in quotes ad strings does
[cmd ][1]
print(str(31)) 31 #I think it should give result as "31" because now it is string
Solution 1:[1]
When string is printed, quotes are usually not added. If you wanna see quote then use the repr() function. For example,
print(repr("31"))
Solution 2:[2]
Because while returning it prints the value, the double quotes are not printed. Though it will be treated as a string, you can verify it by using concatenation through + or string multiplication as str(32)*3 this will give you 323232
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Anshumaan Mishra |
