Advertisement
obernardovieira

string to list

Nov 12th, 2013
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.24 KB | None | 0 0
  1. def strtolist(string) :
  2.     lista = []
  3.     while True:
  4.         x = string.find(',')
  5.         if x == -1:
  6.             num = string
  7.             lista.append(int(num))
  8.             break
  9.         num = string[0:x]
  10.         lista.append(int(num))
  11.         string = string[:0] + string[x+1:]
  12.     return lista
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement