0
def convertToInteger(stringID):
  id = [0, 1, 2, 3, 4, 5, 6]

I need to use a parameter stringID and convert it into the array id in Integer form.

Any tips would be appreciated!

thefourtheye
  • 233,700
  • 52
  • 457
  • 497

1 Answers1

1

Try this, using list comprehensions:

stringId = '0123456'
[int(x) for x in stringId]
=> [0, 1, 2, 3, 4, 5, 6]

Or alternatively, using map:

map(int, stringId)
=> [1, 2, 3, 4, 5, 6]
Óscar López
  • 232,561
  • 37
  • 312
  • 386