Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
slice solution in Clear category for Replace First by Sim0000
def replace_first(items: list) -> list:
return items[1:] + items[:1]
if __name__ == '__main__':
print("Example:")
print(replace_first([1, 2, 3, 4]))
# These "asserts" are used for self-checking and not for an auto-testing
assert replace_first([1, 2, 3, 4]) == [2, 3, 4, 1]
assert replace_first([1]) == [1]
assert replace_first([]) == []
print("Coding complete? Click 'Check' to earn cool rewards!")
Jan. 3, 2020
Comments: