So, as the name says, I'm starting to learn some pythons, and they fail to understand this technique. What I need to do is read in some numbers and save them in a list. The text file is as follows:
0 0 3 50 50 100 4 20
These are basically the coordinates and directions used for the python tortoise to create shapes. I got this part, the only problem is getting them in the correct format. Therefore, I canβt understand how to get these numbers from a file in the [ [0, 0, 3, 50], [50, 100, 4, 20] ] list, each of the four coordinates of which is a list in this large list.
Here is my attempt, but, as I said, I need help - thanks.
polyShape=[] infile = open(name,"r") num = int(infile.readline(2)) while num != "": polyShape.append(num) num = int(infile.readline(2)) infile.close()
user1647372
source share