Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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().
- #PROBLEM 1
- def addOne(l1):
- list1 = l1
- ctr = 0
- result = []
- while ctr < len(l1):
- result = result + str([ctr]+1) + "," + " "
- ctr += 1
- return result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement