Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. Write code that adds 1 to every element in a list. For example, the list [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] would yield [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]. You may not use any built-in functions/methods besides len() and .append().
  2.  
  3. #PROBLEM 1
  4. def addOne(l1):
  5. list1 = l1
  6. ctr = 0
  7. result = []
  8.  
  9. while ctr < len(l1):
  10. result = result + str([ctr]+1) + "," + " "
  11. ctr += 1
  12. return result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement