i have this function:
def add_transaction(list_of_items):
for item in list_of_items:
if item not in item_dict.keys():
raise ValueError("You cannot make a transaction containing items that are not present in the items dictionary because it means that the Store does not has those items available, please add the items to the items dictionary first")
transaction_data.append(list_of_items)
return list_of_items
Do you know how it is possible to transform that into a lambda function? Thanks in advance
Tried to create the lambda function for this function but not sure of how to make it work.
transaction_data) which isn't even defined in the code and it returns only the input passed to it. The only way this will be implemented as a lambda is with a list comprehension and it will be ugly. List comprehensions shouldn't be used for side-effects.raise_ = lambda ex: ex ; f = lambda list_of_items : ([i if i in item_dict.keys() else raise_(ValueError) for i in list_of_items])