Advertisement
Guest User

listexample.py

a guest
Jun 24th, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1.  
  2. our_List = ["itemOne", "itemTwo", "Crusty Bread"]
  3.  
  4. for i in range(len(our_List)): # iterate over list with range(len(our_List))
  5.     current_i_value = i # isolate current value of i (it will incrememnt with each loop)
  6.     associated_list_value = our_List[i] # isolate list value whose index matches current value of i
  7.  
  8.     print("%s: %s" %(current_i_value, associated_list_value)) # print isolated values back to back using string formatting
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement