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
  • 221,210
  • 51
  • 432
  • 478

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
  • 225,348
  • 35
  • 301
  • 374