Skip to content Skip to sidebar Skip to footer

How To Get A List Of Tuples From Several Text Files (part 2: Electric Boogaloo)?

Since my first question wasn't clear enough, I'm going to rewrite it so it's clearer (I'm sorry I wasn't clear in the 1st question). I have a folder that has 46 subdirectories. Eac

Solution 1:

Assuming you have two lists, the first with the number of zeros and the second with the number of ones , you can just rearrange the data at the end:

n_zeros = [1, 2, 3, 4]
n_ones = [5, 6, 7, 8]

pairs = []
for n_zero, n_one in zip(n_zeros, n_ones):
    pairs.append((n_zero, n_one))

print(pairs)

Should return

[(1, 5), (2, 6), (3, 7), (4, 8)]

A better way would be to do the pairing in your main loop, instead of saving two lists.

Post a Comment for "How To Get A List Of Tuples From Several Text Files (part 2: Electric Boogaloo)?"