I have two lists: Names = [John, Marc, Alex] Surnames = [Stuart, Smith, Jones]
I would like to get the next list: [John-Stuart, Marc-Smith, Alex-Jones] How can I get it?
Advertisement
Answer
Use zip()
names = [John, Marc, Alex] surnames = [Stuart, Smith, Jones] fullnames = [f"{name}-{surname}" for name, surname in zip(names, surnames)]