Convert hexadecimal to octal
Problem description
Given n hexadecimal positive integers, output their corresponding octal numbers.
Input format
The first line of input is a positive integer n (1<=n<=10).
In the next n lines, each line contains a string consisting of 0, 9 and capital letters A F, which represents the positive hexadecimal integer to be converted, and the length of each hexadecimal number does not exceed 100000.
Output format
output n lines, each line input corresponding octal positive integer.
[Note] The
entered hexadecimal number will not have leading 0, such as 012A.
The output octal number also cannot have leading 0.
Sample input
2
39
123ABC
Sample output
71
4435274
[Prompt]
First convert the hexadecimal number into a decimal number, and then convert the decimal number into an octal number.
list=[]
n=int(input())
for i in range(n):
x=int(input(),base=16)
y=format(x,'o')
list.append(y)
for i in list:
print(i)
Reference knowledge