SHARE
TWEET

Untitled

a guest May 25th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top