I try to use list comprehension to replace the for loop.
original file is
2 3 4 5 6 3
1 2 2 4 5 5
1 2 2 2 2 4
for loop
line_number = 0
for line in file:
line_data = line.split()
Cordi[line_number, :5] = line_data
line_number += 1
output is
[[2 3 4 5 6 3]
[1 2 2 4 5 5]
[1 2 2 2 2 4]]
if use list comprehension instead, for what I can think of is (I have to change the data type to int, so it can be plotted in later part of the program)
Cordi1= [int(x) for x in line.split() for line in data]
but the output is
[1, 1, 1]
but line.split() for line in data
is actually a list, and if I try
Cordi1 = [int(x) for x in name of the list]
it works, why this happens?