Advertisement
Guest User

Untitled

a guest
May 25th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. names = ['Peter Parker', 'Clark Kent', 'Wade Wilson', 'Bruce Wayne']
  2. heroes = ['Spiderman', 'Superman', 'Deadpool', 'Batman']
  3.  
  4. # access elements of second list using loop index
  5. for index, name in enumerate(names):
  6. hero = heroes[index]
  7. print(f'{name} ---> {hero}')
  8.  
  9. # pythonic way to do the same
  10. for name, hero in zip(names, heroes):
  11. print(name + " ---> "+ hero)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement