Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. items = ["Cheese", "Tomato", "Potato", "Cucumber", "Salt", "Pepper"]
  2.  
  3. def beautifulList(array):
  4. string = ""
  5. for index, item in enumerate(array, start=1):
  6. string += "and " + item if index == len(items) else item + ", "
  7. return string
  8.  
  9. print(beautifulList(items))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement