f | def function_that_says_ni(*args,**kwargs): | f | def function_that_says_ni(*args,**kwargs): |
| | | |
| bushes = [] | | bushes = [] |
n | bushesNames = [] | n | bushes_names = [] |
| for arg in args: | | for arg in args: |
| if type(arg) is dict: | | if type(arg) is dict: |
| if "name" not in arg: | | if "name" not in arg: |
| continue | | continue |
| if type(arg["name"]) is not str: | | if type(arg["name"]) is not str: |
| continue | | continue |
n | bushName = arg["name"].lower() | n | bush_name = arg["name"].lower() |
| if bushName not in ["shrub","храст","bush"]: | | if bush_name not in ["shrub", "храст", "bush"]: |
| continue | | continue |
| bushes.append(arg) | | bushes.append(arg) |
| | | |
| for key,value in kwargs.items(): | | for key,value in kwargs.items(): |
| if type(value) is dict: | | if type(value) is dict: |
| if "name" not in value: | | if "name" not in value: |
| continue | | continue |
| if type(value["name"]) is not str: | | if type(value["name"]) is not str: |
| continue | | continue |
n | bushName = value["name"].lower() | n | bush_name = value["name"].lower() |
| if bushName not in ["shrub","храст","bush"]: | | if bush_name not in ["shrub", "храст", "bush"]: |
| continue | | continue |
| bushes.append(value) | | bushes.append(value) |
n | bushesNames.append(key) | n | bushes_names.append(key) |
| | | |
n | letters = [letter for name in bushesNames for letter in name] | n | letters = [letter for name in bushes_names for letter in name] |
| letters = set(letters) | | letters = set(letters) |
| letters_count = len(letters) | | letters_count = len(letters) |
| | | |
| bushes_cost = 0 | | bushes_cost = 0 |
| for bush in bushes: | | for bush in bushes: |
| if "cost" in bush: | | if "cost" in bush: |
| if (type(bush["cost"]) is int) or (type(bush["cost"]) is float): | | if (type(bush["cost"]) is int) or (type(bush["cost"]) is float): |
t | bushes_cost+=bush["cost"] | t | bushes_cost += bush["cost"] |
| | | |
| bushes_cost = round(bushes_cost, 2) | | bushes_cost = round(bushes_cost, 2) |
| | | |
| if int(bushes_cost) == 0: | | if int(bushes_cost) == 0: |
| return "Ni!" | | return "Ni!" |
| if letters_count % int(bushes_cost) != 0: | | if letters_count % int(bushes_cost) != 0: |
| return "Ni!" | | return "Ni!" |
| if bushes_cost > 42: | | if bushes_cost > 42: |
| return "Ni!" | | return "Ni!" |
| | | |
| return f"{bushes_cost:.2f}лв" | | return f"{bushes_cost:.2f}лв" |
| | | |
| | | |
| | | |