0

I've the following nested dictionary:

[[u'bob', u'fred'], [u'sanders', u'harris'], [u'bob@xyz.com', u'fredharris@abc.com'], ['user1 password', 'user2 password']]

Printing Key/Value I get:

1: bob
1: fred
2: sanders
2: harris
3: bob@xyz.com
3: fredharris@abc.com
4: user1 password
4: user2 password

I cannot find a way in Python 2.7 to get the following output:

bob[tab]sanders[tab]bob@xyz.com[tab]user1 password

fred[tab]harris[tab]fredharris@abc.com[tab]user2 password

Could you please assist me?

1 Answers1

0

This snippet should solve your problem:

mylist = [[u'bob', u'fred'], [u'sanders', u'harris'], [u'bob@xyz.com', u'fredharris@abc.com'], ['user1 password', 'user2 password']]

for i in range(len(mylist[0])):
    print '%s\t%s\t%s\t%s' % (mylist[0][i], mylist[1][i], mylist[2][i], mylist[3][i])

Note that your "nested dictionary" is not a dictionary.

machnic
  • 2,304
  • 2
  • 17
  • 21
  • Thank you, I must of created it wrongly trying to find a solution to my problem using pwords = {} and inside the loop pwords.setdefault(1, []).append(fn) pwords.setdefault(2, []).append(ln) pwords.setdefault(3, []).append(em) – user12154071 Oct 02 '19 at 16:58
  • You're welcome. If you find this answer helpful, please consider marking it as an accepted answer. – machnic Oct 03 '19 at 07:45