Print multiple lists each in one column

0

I have five lists that have been extracted from an Excel table in CSV. I would like to know how I can print them in the terminal side by side, I believe it can be done with a for loop, but I did not get the syntax.

a = []
b = []
c = []
d = []
e = []

dataset = open ("Teste_Plotagem.csv","r")

for line in dataset:
    line = line.strip()
    A,B,C,D,E = line.split(";")
    a.append(A)
    b.append(B)
    c.append(C)
    d.append(D)
    e.append(E)

dataset.close()

print(a)
print(b)
print(c)
print(d)
print(e)
    
asked by anonymous 29.12.2018 / 03:19

1 answer

1
a = ["Pedro", "Ricardo", "Renato", "Sonia", "Rosana"]
b = ["Analista", "Financeiro", "Controlador", "Produção", "Logística"]
c = [4000, 3100, 5000, 1900, 1400]

x = 0
for i in a:
    print("{}\t\t\t{}\t\t\t{}".format(a[x], b[x], c[x]))
    x+=1

Output:

Pedro           Analista            4000
Ricardo         Financeiro          3100
Renato          Controlador         5000
Sonia           Producaoo           1900
Rosana          Logistica           1400

How about? You can also create a single list:

a = ["Pedro", "Ricardo", "Renato", "Sonia", "Rosana"]
b = ["Analista", "Financeiro", "Controlador", "Produção", "Logística"]
c = [4000, 3100, 5000, 1900, 1400]

lst = []

x = 0
for i in a:
    temp_lst = [a[x], b[x], c[x]]
    lst.append(temp_lst)
    x+=1

for line in lst:
    print(line)

Output:

['Pedro', 'Analista', 4000]
['Ricardo', 'Financeiro', 3100]
['Renato', 'Controlador', 5000]
['Sonia', 'Produção', 1900]
['Rosana', 'Logística', 1400]
    
29.12.2018 / 18:56