Last active
June 2, 2020 15:43
-
-
Save JohnsonLuu/897fc683038033c72a9ef13edcecbf8b to your computer and use it in GitHub Desktop.
This file contains 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
""" | |
Write a function named append_sum that has one parameter — a list named named lst. | |
The function should add the last two elements of lst together and append the result to lst. It should do this process three times and then return lst. | |
For example, if lst started as [1, 1, 2], the final result should be [1, 1, 2, 3, 5, 8]. | |
""" | |
#Write your function here | |
def append_sum(lst): | |
lst.append(lst[-2] + lst[-1]) | |
lst.append(lst[-2] + lst[-1]) | |
lst.append(lst[-2] + lst[-1]) | |
return lst | |
#Uncomment the line below when your function is done | |
print(append_sum([1, 1, 2])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment