0

I have an input on the form 'A7-A5'

How can i get that input to a list like: [['A',7],['A',5]]

1
  • Is it always one letter and one digit? Commented Nov 13, 2011 at 14:48

1 Answer 1

5
>>> a = "A7-A5"
>>> b = [[i[0], int(i[1])] for i in a.split("-")]
>>> b
[['A', 7], ['A', 5]]
Sign up to request clarification or add additional context in comments.

2 Comments

or, map(list, a.split('-'))
@Andrew: That won't convert the digit to an integer, though.

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.