I think you actually have more confusion.
The original error is that you are trying to call split in the entire list of strings, and you cannot split list of strings, but only the string. So you need to split each line, not all.
And then you do for points in Type and expect each such points give you new x and y . But that will not happen. Types are just two values, x and y , so first the points will be x , and then the points will be y , and then you will do it. So, again, you need to loop through each row and get the x and y values ββfrom each row, not a loop through one Types from one row.
So, everything should go inside the loop over each line in the file and split into x and y once for each line. Like this:
def getQuakeData(): filename = input("Please enter the quake file: ") readfile = open(filename, "r") for line in readfile: Type = line.split(",") x = Type[1] y = Type[2] print(x,y) getQuakeData()
As a side note, you really should close file, ideally with the with statement, but I will get to the end.
Interestingly, the problem here is not that you are too new to, but that you are trying to solve the problem in the same abstract form as the expert, and simply do not know the details. This is quite doable; you just need to be explicit with respect to function mapping, and not just do it implicitly. Something like that:
def getQuakeData(): filename = input("Please enter the quake file: ") readfile = open(filename, "r") readlines = readfile.readlines() Types = [line.split(",") for line in readlines] xs = [Type[1] for Type in Types] ys = [Type[2] for Type in Types] for x, y in zip(xs, ys): print(x,y) getQuakeData()
Or, the best way to write what might be:
def getQuakeData(): filename = input("Please enter the quake file: ")
Finally, you can take a look at NumPy and Pandas, libraries that give you the ability to implicitly display functionality over the entire array or frame of data in much the same way you tried.