JBlock
JBlock

Reputation: 11

How to print out a string to have multiple lines in the print out

So i'm using python and I have an email dict being pulled from a large .csv column file where some values might have multiple values. I'm implementing this column into a vertex for a graphing database so order is key. I am using Gremlin API.

Here's what I have for my code:

contact_email_name_map = defaultdict()

for i in range(len(contact_email)):
    contact_email_name_map[contact_email[i]] = account_name[i]  

for key, value in contact_email_name_map.items():
    print(key, "-------------------", value)

what happens now:

output:
[email protected]
[email protected]
[email protected];[email protected]
[email protected]

what I would like to happen:

output:
[email protected]
[email protected]

[email protected] 
[email protected]

[email protected]

Does anyone know how to solve this issue?

I hope this makes sense

Upvotes: 1

Views: 46

Answers (1)

iacob
iacob

Reputation: 24201

You can split on the delimiter:

for key, value in contact_email_name_map.items():
    for email in key.split(";"):
        print(email, "-------------------", value)

Upvotes: 1

Related Questions