-4

I have got data to print. I create list but I can't print it. My list is:

NEW_2 = [['ID', 'FK'], ['1', '1'], ['2', '1'], ['5', '3'], ['6', '2']]

And after print it should be like that:

ID  FK
1   1
2   1
5   3
6   2

After all, I have to save that to the file, that will looks like that. Can anyone help?

Dawid
  • 347
  • 2
  • 15

2 Answers2

0
>>> NEW_2 = [['ID', 'FK'], ['1', '1'], ['2', '1'], ['5', '3'], ['6', '2']]
>>> for cols in NEW_2:
...     print '{:5}{:5}'.format(*cols)

Prints:

ID   FK   
1    1    
2    1    
5    3    
6    2    
dawg
  • 98,345
  • 23
  • 131
  • 206
0

After all this time and better skills, I have a good and easy way to do that:

NEW_2 = [['ID', 'FK'], ['1', '1'], ['2', '1'], ['5', '3'], ['6', '2']]

for i in NEW_2:
    print i[0],i[1]
Martin Evans
  • 45,791
  • 17
  • 81
  • 97
Dawid
  • 347
  • 2
  • 15