
Complete the following Python function: ```python def chang...
Prompt
Complete the following Python function: ```python def change_base(x: int, base: int): """Change numerical base of input number x to base. return string representation after the conversion. base numbers are less than 10. >>> change_base(8, 3) '22' >>> change_base(8, 2) '1000' >>> change_base(7, 2) '111' """ ```
Answer guidance
Canonical solution (function body): ret = "" while x > 0: ret = str(x % base) + ret x //= base return ret
Drag to resize
Drag to resize
Drag to resize