0

My task is doing a base converter. I thought of switching it to base 10 and then switch it to the wanted base. So I want to get a string and them put it in a list, and slice it and after that to use the sliced parts:

s=input()
NumList=[s]
NumList[::]

Is there any way of doing it? Do you have any better idea?

4
  • 4
    I've re-read the question a couple of times, and can't make heads nor tails of it. Commented Dec 4, 2012 at 16:55
  • 1
    Your question is very unclear. I can understand that you want to convert numbers from one base to another base. But I cannot understand anything past that point. What does converting numbers between bases have to do with slicing strings? Commented Dec 4, 2012 at 16:57
  • I'm sorry, I'll try to clear it: Commented Dec 4, 2012 at 17:00
  • my input should be at this form: 1111 2 5 (means the number 1111 in base 2 needs to be switched to base 5) Commented Dec 4, 2012 at 17:01

2 Answers 2

1

You split up your input string like this:

(number, from_base, to_base) = s.split()

Sign up to request clarification or add additional context in comments.

2 Comments

thank you! i tried now to do power: from_base^i(some variable)
while(i,pow(from_base,i),i+1) : sum+=i
0

You can split the string received from input by space and thereafter process it according to your needs.

s = input()
ls = s.split() // ls is a list.

1 Comment

just s.split() space (' ') is default

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.