lynulx

Untitled

Jan 12th, 2022
1,177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.35 KB | None | 0 0
  1. from string import digits, ascii_lowercase
  2.  
  3.  
  4. def from_n_to_10(num: str, base: int = 2):
  5.     alphabet = digits+ascii_lowercase
  6.     assert base in range(2, 10+len(alphabet) + 1)
  7.     res = 0
  8.     for i in num:
  9.         digit = alphabet.index(i)
  10.         assert digit < base
  11.         res = res*base + digit
  12.     return res
  13.  
  14.  
  15. print(from_n_to_10(input()))
  16.  
Advertisement
Add Comment
Please, Sign In to add comment