Write a program that prompts the user for input of a positive integer n and converts that integer into each base b between 2 and 16 (using a for loop). I'm halfway there (still have to convert the numbers to letters for bases 10+).
When I run the program, the error pops up. I thought int() took integers as parameters?
n = int(input("Enter a positive number: "))
while n < 0:
n = int(input("Please input a positive number: "))
for x in range(2, 17): #x being the iteration of base numbers
baseConvert = int(n, x)
textString = "{} = {} in base {}".format(n, baseConvert, x)
print(textString)
Traceback (most recent call last):
File "/tmp/sessions/fdb8f9ea1d4915eb/main.py", line 8, in <module>
baseConvert = int(n, base)
TypeError: int() can't convert non-string with explicit base