I'm looking to break up a file with space delimiters. Its really just a list of numbers with spaces in between them, and I need to put each of the numbers in a list as separate entries. However, they are all on one line like so:

5 7 6 35 346 245 etc.

I have been told there is a command for this (like split or tokenize) but I cannot find it. Thanks!

>>> line_of_numbers = "5 7 6 35 346 245"
>>> list_of_numbers = line_of_numbers.split()
>>> print list_of_numbers
['5', '7', '6', '35', '346', '245']
numbers="12560 36520 1763"
numberlist= numbers.split()
print("First number is %i." % numberlist[0])
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.