Write a programExercise 4/4Intermediate30 XP

Converting to a base

Task

Write a function do_sustavy(n, zaklad) that converts a non-negative whole number n to the base zaklad (2 to 9) and returns the result as a string.

For example do_sustavy(10, 2) returns "1010" and do_sustavy(255, 8) returns "377". Do not use bin, oct or format.

Examples

  • Call

    print(do_sustavy(10, 2))

    Expected output

    1010
  • Call

    print(do_sustavy(255, 8))

    Expected output

    377

Rules

  • Convert the number by division with remainder - no bin, oct or format.

After you submit, 6 hidden tests will also check your solution: zero, base three, smaller than the base, equal to the base, a large number, returns a string.

Python starts the first time you run code.

Ctrl+Enter runs the program. Tab indents. Press Esc, then Tab, to leave the editor.

Input (stdin)

Each line = one call to input().

Output

Hints

Try it yourself first. Each hint reveals a little more - and lowers the reward a little.

Signed out, hints are free - but no XP is awarded either.

Solution

The solution unlocks after the last hint.