python convert string of numbers to list of numbers [duplicate]

  • A+
Category:Languages
l='2,3,4,5,6' 

expecting:

[2,3,4,5,6] 

In python how can I convert into above format

first one is string of some numbers I am expecting list of same numbers.

 


As simple as this:

print [int(s) for s in l.split(',')] 

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: