1def function_that_says_ni(*args, **kwargs):
2 valid_values_for_names = {"храст", "shrub", "bush"}
3 total_price = 0.0
4 key_characters = set()
5
6 for arg in args:
7 if isinstance(arg, dict) and "name" in arg and arg["name"].lower() in valid_values_for_names:
8 total_price += arg.get("cost", 0)
9
10 for key, value in kwargs.items():
11 if isinstance(value, dict) and "name" in value and value["name"].lower() in valid_values_for_names:
12 total_price += value.get("cost", 0)
13 key_characters.update(key)
14
15 if total_price > 42.00:
16 return "Ni!"
17
18 unique_letters_count = len(set(key_characters))
19
20 integer_price = int(total_price)
21
22 if integer_price == 0 or unique_letters_count % integer_price != 0:
23 return "Ni!"
24 else:
25 return f"{total_price:.2f}лв"
..........
----------------------------------------------------------------------
Ran 10 tests in 0.000s
OK
22.10.2024 11:08