20 lines
632 B
Python
20 lines
632 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):
|
|
result = "".join(sorted(set(word), key=word.index))
|
|
print(word, len(word), "\n", result, len(result))
|
|
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:
|
|
animal_dictionary = {"Lion": "Growl", "Dog": "Bark", "Cat": "Meow"}
|
|
return animal_dictionary.get(animal, "Not found.")
|