Skip to content

Instantly share code, notes, and snippets.

@pedromassango
Last active August 19, 2021 21:32
Show Gist options
  • Save pedromassango/1218637c03dc6116cd211069595d0a70 to your computer and use it in GitHub Desktop.
Save pedromassango/1218637c03dc6116cd211069595d0a70 to your computer and use it in GitHub Desktop.
# Manipulating Lists and Tuples
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