task1.py 449 B

123456789101112131415161718
  1. def convert_base(number):
  2. """
  3. Given a number represented as a list of digits in a base,
  4. convert it to the same number written as a list of digits in the other base.
  5. >>> convert_base([5, 9, 5, 7], 10, 6)
  6. [4, 3, 3, 2, 5]
  7. >>> convert_base([0, 0, 3, 2, 3, 3], 5, 20)
  8. [1, 2, 3]
  9. >>> convert_base([1, 2, 1, 0], 3, 17)
  10. [2, 14]
  11. >>> convert_base([1, 2, 1, 6], 7, 5)
  12. [3, 3, 0, 4]
  13. """
  14. # Your code here...