Created
August 9, 2016 15:49
-
-
Save Gwith/a40bbf726a76b9dd8e1c5c387683e099 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def append_twice_okay(a_list, val): | |
| """mutates argument.""" | |
| a_list.append(val) | |
| a_list.append(val) | |
| def append_twice_good(a_list, val): | |
| """returns new list.""" | |
| return a_list + [val, val] | |
| nums_okay = [1, 2, 3] | |
| append_twice_okay(nums_okay, 7) | |
| print(nums_okay) | |
| nums_good = [1, 2, 3] | |
| new_list = append_twice_good(nums_good, 7) | |
| print(new_list) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment