George is getting tired of the decimal number system. He intends to switch and use the…
- User
George is getting tired of the decimal number system. He intends to switch and use the septenary (base 7) number system for his future needs. Write a program to help George start his transformation into the septenary number system by taking in a list of decimal numbers and print out the corresponding septenary number. Input A list of numbers in decimal format ending with -1.
Output A list of numbers in septenary.
Example Input: 1 2 88 42 99 -1
Output: 1 2 154 60 201
Assistant
pythonn_list = input().split() result = [] for s in n_list: num = int(s) if num == -1: break if num == 0: result.append('0') continue digits = [] n = num while n > 0: digits.append(str(n % 7)) n = n // 7 sept = ''.join(reversed(digits)) result.append(sept) print(' '.join(result))
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.