PDA

View Full Version : extract python list from these strings?



loell
May 15th, 2007, 04:33 AM
hi ,

how do i extract these numbers as list in python?
ie:

12-10-20
34-90-67
56-38-41

each line is a single list.

thanks in advance :)

ghostdog74
May 15th, 2007, 05:13 AM
you can use split(). the result is a list. you can store the list as a variable where necessary
eg


>>> "12-10-20".split("-")
['12', '10', '20']
>>>

loell
May 15th, 2007, 05:19 AM
oh thanks, i didn't know about the split thing :)