How To Return A String Without Quotes Python 3
Solution 1:
You are either echoing the return value in your interpreter, including the result in a container (such as a list, dictionary, set or tuple), or directly producing the repr()
output for your result.
Your function (rightly) returns a string. When echoing in the interpreter or using the repr()
function you are given a debugging-friendly representation, which for strings means Python will format the value in a way you can copy and paste right back into Python to reproduce the value. That means that the quotes are included.
Just print the value itself:
>>>result = bukiyip_to_decimal(12)>>>result
'110'
>>>print(result)
110
or use it in other output:
>>> print('The Bukiyip representation for 12 is {}'.format(result))
The Bukiyip representation for12is110
Solution 2:
int()
doesn't work? The quotes are not for decoration, you see. They are part of the string literal representation. "hello"
is a string. It is not hello
with quotes. A bare hello
is an identifier, a name. So you don't wanna strip quotes from a string, which doesn't make any sense. What you want is a int
.
Post a Comment for "How To Return A String Without Quotes Python 3"