diff --git a/12.26.py b/12.26.py new file mode 100644 index 0000000..1787892 --- /dev/null +++ b/12.26.py @@ -0,0 +1,24 @@ +def prepare(f, export_list = []): + lines = f.readlines() + for line in lines: + export_list.append(line.split()) + return export_list + +def export(export_list, amount = 0, countries = []): + product = input('Ввести назву товару: ') + for list in export_list: + if product.title() in list: + countries.append(list[1]) + amount += int(list[2]) + if amount == 0: + print('Товар не знайдено') + export(export_list) + else: + product_info = {'countries': countries, 'amount': amount} + print(product_info) + + +if __name__ == '__main__': + f = open("hw/12.26.txt") + export_list = prepare(f) + export(export_list) \ No newline at end of file diff --git a/12.26.txt b/12.26.txt new file mode 100644 index 0000000..95fcf87 --- /dev/null +++ b/12.26.txt @@ -0,0 +1,6 @@ +Car Spain 1000 +Airplane Italy 450 +Car Ukraine 320 +Ship Ukraine 240 +Ship USA 115 +Car Italy 410