Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Replace Last by hamid.chayeb97
from typing import Iterable
def replace_last(line: list) -> Iterable:
# your code here
if line == []:
return []
last = line.pop()
line.insert(0 , last)
return line
print("Example:")
print(list(replace_last([2, 3, 4, 1])))
assert list(replace_last([2, 3, 4, 1])) == [1, 2, 3, 4]
assert list(replace_last([1, 2, 3, 4])) == [4, 1, 2, 3]
assert list(replace_last([1])) == [1]
assert list(replace_last([])) == []
print("The mission is done! Click 'Check Solution' to earn rewards!")
Oct. 3, 2024
Comments: