original = raw_input('Enter numeric string: ')
base = int(raw_input('What base is the number? '))
place = 1
total = 0
original = original[ : :-1] # reverse for convenience
for symbol in original:
if symbol.isdigit( ):
value = int(symbol)
else:
value = 10 + ord(symbol) - ord('A')
total += value * place
place *= base
print total
(click
to see it run live)
There is a bit of care needed with the precise stopping condition, and floating-point arithmeitc is imprecise. But the most accurate attempt, which works on both positive and negative step sizes is the following:
result = [start + k * step for k in range(int(math.ceil((stop-start)/step)))]
rnaList = [rnaCode[dnaCode.index(base)]] for base in dna]
uniq = [ orig[i] for i in range(len(orig)) if orig.index(orig[i]) == i ]