So, I have this file that has data set up like this:
Bob 5 60
Carl 7 80
Rick 8 100
Santiago 7 30
I need to separate each part into three different lists. One for the name, one for the first number, and one for the second number.
But I don’t really understand, how exactly do I extract those parts? Also, let’s say I want to make a tuple with the first line, with each of the different parts (the name, first number, and second number) into a single tuple?
I just don’t get how I extract that information.
I just learned how to read and write text files…so I’m pretty clueless.
EDIT: As a note, the text file already exists. The program I’m working on needs to read the text file, which has its data formatted in the way I listed.
You can split each line on whitespace:
zip(*iterable)re-arranges the 3 columns into 3 lists.