Skip to content

Instantly share code, notes, and snippets.

@eff-kay
Last active January 10, 2023 06:51
Show Gist options
  • Save eff-kay/26a14701a5b66d2a6aa3754a1604037c to your computer and use it in GitHub Desktop.
Save eff-kay/26a14701a5b66d2a6aa3754a1604037c to your computer and use it in GitHub Desktop.
def bad_prepend(xs, ys):
if not xs:
return ys
else:
final_list = bad_prepend(xs[1:], ys)
final_list.insert(0, xs[0])
return final_list
x = [3,2,1]
y = [0,1,2]
ret = bad_prepend(x,y)
# prints [3,2,1, 0,1,2]
print(ret)
x = [6,7]
y[3] = 100
ret = bad_prepend(x,y)
# whats the output of the following??
print(x)
print(y)
print(ret)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment