Advertisement
Guest User

Untitled

a guest
May 27th, 2015
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. while True:
  2. divisor = input("convert base10 to a base between 1 and 9.\nenter a base or E to exit: ")
  3.  
  4. if divisor.upper() == "E":
  5. break
  6.  
  7. base10 = int(input("Enter a number base10: "))
  8. basex = []
  9.  
  10. while base10 != 0:
  11. num = base10%int(divisor)
  12. basex.append(str(num))
  13. base10 = base10//int(divisor)
  14. #print(num, base10)
  15.  
  16. print("base" + divisor + ": ", "".join(basex[::-1]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement