Fill a list of 2 lists from split string This might be too trivial of a question for Code Review, but here goes:

Assume I have text file with content:

A 1
B 2
C 3
D 4


And I want a list like [[1,2,3,4],["A","B","C","D"]] created by Python's list comprehensions.

My code accomplishes this, but it seems like I jump through way too many loops:

with open('textFile.txt') as f:
    lines = f.readlines()

z = [y for y in map(list, list(zip(*[x.split() for x in lines])))]


Is there an easier way to achieve this using list comprehension?
If you're going to use map, then it's simpler to surround it in a list() call, then a list comprehension.
Rather than using list(map(list, it)), you can instead use a list comprehension.

[list(i) for i in it]

You don't need to use list(zip()), it only hinders performance and readability.
You don't have to use a list comprehension with *, instead you could use a generator comprehension.
You don't have to use f.readlines(), if you perform the comprehension in the with.


Merging this all together gets:

with open('textFile.txt') as f:
    z = [list(i) for i in zip(*(j.split() for j in f))]