Last active
January 10, 2023 06:51
-
-
Save eff-kay/26a14701a5b66d2a6aa3754a1604037c 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
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