i've got write single-input module can convert decimals bukiyip (some ancient language counting base of 3 or 4). purpose of assignment, need work base 3.
i've written code this, returns bukiyip number quotes, leaving me answer such '110' 12.
please me understand how work around this? i'm new python , keen learn explanations appreciated.
def bukiyip_to_decimal(num): convert_to_string = "012" if num < 3: return convert_to_string[num] else: return bukiyip_to_decimal(num//3) + convert_to_string[num%3]
i've tried following, errors.
else: result = bukiyip_to_decimal(num//3) + convert_to_string[num%3] print(int(result))
you either echoing return value in interpreter, including result in container (such list, dictionary, set or tuple), or directly producing repr()
output result.
your function (rightly) returns string. when echoing in interpreter or using repr()
function given debugging-friendly representation, strings means python format value in way can copy , paste right python reproduce value. means quotes included.
just print value itself:
>>> result = bukiyip_to_decimal(12) >>> result '110' >>> print(result) 110
or use in other output:
>>> print('the bukiyip representation 12 {}'.format(result)) bukiyip representation 12 110
Comments
Post a Comment