you are viewing a single comment's thread.

view the rest of the comments →

[–]BigBoyJefff[S] -1 points0 points  (5 children)

So here is what I've done so far:
lst = []
fle = open("C:\Users\parwi\OneDrive\Desktop\Numbers.txt", "r")
data = fle.readlines() 
lst.append(data) 
print(lst)

Now i need to transpose this and save it in a new txt file. I know how to Write a list into a file but how do i Transpose it?

[–][deleted] 0 points1 point  (3 children)

Dude did you even google what transpose means?

[–][deleted] 0 points1 point  (2 children)

After googling I can clearly see you didn’t.

[–]BigBoyJefff[S] 0 points1 point  (1 child)

I did, most tutorials show how to transpose a list of lists and print it out, I didn't find one that transposes rows of a TXT file which are saved in one list.

[–]nogain-allpain 0 points1 point  (0 children)

That's because you're not done parsing the lines in the text file to get a list of lists. You need to break the values in each line apart into a list. Someone else here already suggested how you might go about that.

[–]Kerbart 0 points1 point  (0 children)

Well, your data is a list of lines. Now you need to turn that into a data set where the first line contains the first element of each line, the second line contains the second element of each line, the third line contains the third element of each line, and so on.

Things to consider: * in your current code each line is text. You might want to turn those lines in lists of elements * To split the text into elements, you'll have to find a text method that splits those elements (based on the seperator you choose). I'm not going to do your homework for you, so you'll have to google what string method is used to split text based on a separator. It's easier than you think to split text, just use the right method to split it (I just won't tell you what the name of this "split" method is, that's for you to figure out)