how can I fix the task so that it can output [21, 2, 33], not [21,5,3]. I'm not sure what can i change
def to_number(digits): result=digits[0] for el in digits[1:]: result=result*10 result=result+el return result print(to_number([21, 2, 33]))
It's definitely something from here result=result+el because it collects the next element
- result = 22 - result = 22 x 10 = 220 - result = 220 + 2 = 222 - result = 222 x 10 = 2220 - result = 2220 + 33 = 2253
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)