Jul-10-2022, 12:51 PM
Hi, how can i change this code to work for two-digit numbers or three-digit number?
For now only work for single digit numbers, tried to change algorthm but didnt work.
It has to output this:
input: [ 21, 12, 1]
output: 21121
For now only work for single digit numbers, tried to change algorthm but didnt work.
def to_number(digits): result=digits[0] for el in digits[1:]: result=result*10 result=result + el return resultNow the ouput is 2221 - i think is because of this line result=result + el
It has to output this:
input: [ 21, 12, 1]
output: 21121