-1

I need to convert a number to base 10. my input is from this form:1111(the number) 5(on which base) 10(to base).i wrote this code:

s=input()
(number, from_base, to_base) = s.split()
NumList=[number]
NumList.reverse()

i=0
sum=0


while (i< (index.from_base)):

  (i,pow(from_base,i),i+1) 
  sum=sum+i


print (sum)

I want to do: number^the from_base index.I tried also to do i**from_base\i^^from_base. I tried also to add the command NumList.index() but it didn't work.

thank you!

ThiefMaster
  • 310,957
  • 84
  • 592
  • 636

1 Answers1

1

The commenters have already addressed the deeper problem that you're trying to solve.

But the superficial question that you're asking can be best solved by using Python's enumerate: Feed it a sequence of values and it returns a sequence of (index, value) pairs.

http://docs.python.org/2/library/functions.html#enumerate

Mike Sandford
  • 1,315
  • 10
  • 22