Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def n1(n, base1, base2):
- temp, now = 0, 1
- for i in n[::-1]:
- if '0' <= i <= '9':
- temp += int(i) * now
- else:
- temp += (ord(i) - ord('A') + 10) * now
- now *= base1
- n = ''
- while temp != 0:
- now = temp % base2
- if now < 10:
- n += str(now)
- else:
- n += chr(now - 10 + ord('A'))
- temp //= base2
- print(n[::-1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement