문제

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
     .                .
     .                .
도움이 되었습니까?

해결책

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top