18 lines
526 B
Python
18 lines
526 B
Python
if __name__ == "__main__":
|
|
# 5.3
|
|
nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
|
print(nums[-3:] + nums[:-3])
|
|
|
|
# 5.4
|
|
def remove_duplicates(word: str):
|
|
return "".join(sorted(set(word), key=word.index))
|
|
remove_duplicates("Donaudampfschiffahrtsgesellschaftsstewardess")
|
|
|
|
# 5.5
|
|
nums = [[1, 2, 3], [2, 1, 3], [4, 0, 1]]
|
|
nums.sort(key=lambda x: x[1])
|
|
|
|
# 5.6
|
|
def get_animal_sound(animal: str) -> str:
|
|
return {"Lion": "Growl", "Dog": "Bark", "Cat": "Meow"}.get(animal, "Not found.")
|