Last active
August 19, 2021 21:32
-
-
Save pedromassango/1218637c03dc6116cd211069595d0a70 to your computer and use it in GitHub Desktop.
# Manipulating Lists and Tuples
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
def add_layer(triangle): | |
# Add a layer to Pascal's triangle. | |
# Each layer should be a tuple. | |
last = triangle[-1] | |
newTuple = [] | |
for i in range(len(last)): | |
newTuple.append(last[i] + last[i-1]) | |
newTuple.append(1) | |
triangle.append(tuple(newTuple)) | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment