Domanda

I have have two lists and I want to print them out in the shell as such:

List 1 name ----- List 2 name 
     1                a
     2                b
     .                .
     .                .
È stato utile?

Soluzione

You can do it as:

a = ['apple', 'banana', 'cat']
b = ['dinosaur', 'raspberry', 'elephant']

for c,d in zip(a,b):
    print '{:>15}     {:<15}'.format(c,d)

[OUTPUT]
 apple     dinosaur  
banana     raspberry 
   cat     elephant
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top