Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from typing import Iterable
- def replace_first(items: list) -> Iterable:
- """
- In a given list the first element should become the last one.
- An empty list or list with only one element should stay the same.
- """
- item = items.pop(0)
- return items.append(item)
- print(list(replace_first([1, 2, 3, 4])))
Advertisement
Add Comment
Please, Sign In to add comment