1
votes
print(contact.lastname,",", contact.firstname,",", contact.email,",", contact.phone)

The output is:

Polo , Marco , cam.com , 444-444-4444

I want:

Polo, Marco, cam.com, 444-444-4444
2

2 Answers

4
votes
string.replace(" ,",",")

You can use the replace method to substitute " ," with "," and then you have what you want.

Although, with your example, just do:

print(contact.lastname+",",contact.firstname+",",contact.email+",",contact.phone)

When you do print(v,w) you automatically add a space. So if you do print(v,",",w) you have the space you try to get rid of. If, instead, you do print(v+",") then you have no space between the text in v and the comma.

2
votes

You can use string format :

print(f"{contact.lastname},{contact.firstname},{contact.email},{contact.phone}")

Or if you want to keep multiple parameters in the print funciton, use the sep (separator) parameter :

print(a, b, c, sep=',')