From db15acc2b3efaa1aeea9d0bf2ccf99d2f7e5729d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D1=83=D0=B7=D0=B0=D0=BD=D0=BE=D0=B2=20=D0=9F=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=BE?= <124675990+CrazyDuck192@users.noreply.github.com> Date: Tue, 21 Mar 2023 20:00:39 +0200 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=BC=D0=B0=D1=88=D0=BD=D1=8F=20?= =?UTF-8?q?=D1=80=D0=BE=D0=B1=D0=BE=D1=82=D0=B0=20=E2=84=964=20(=E2=84=961?= =?UTF-8?q?2.26)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 12.26.py | 24 ++++++++++++++++++++++++ 12.26.txt | 6 ++++++ 2 files changed, 30 insertions(+) create mode 100644 12.26.py create mode 100644 12.26.txt 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