Created
August 8, 2016 23:00
-
-
Save Gwith/9cbd49c652758cc851f06c7593d7ea01 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