-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmorhun_hw4.py
67 lines (49 loc) · 1.54 KB
/
morhun_hw4.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# -*- coding: utf-8 -*-
"""the4.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1TN2z57Ir0dujxhtwUuGpP2-ncetjh_G7
"""
#Muhammed Orhun Gale
product_list = []
date_list = []
year_list = []
info = input("Products and their purchasing dates: ")
info_list = info.split(",")
price = input("Prices of the products: ")
price_list = price.split(",")
for element in info_list:
temp_list = element.split("_")
product_list.append(temp_list[0])
date_list.append(temp_list[1])
temp_list.clear()
for y in date_list:
plist = y.split(".")
year_list.append(plist[2])
check = True
while check == True:
interval = input("Starting Year-Ending Year: ")
if len(interval) != 9:
print("Years were not entered in correct format.")
else:
year1,year2 = interval.split("-")
if year1.isdigit() == False or year2.isdigit() == False:
print("Years were not entered in correct format.")
else:
dif = int(year2) - int(year1)
if dif >= 0:
check = False
else:
print("Years were not entered in correct format.")
prod_name = input("Product Name: ")
while prod_name not in product_list:
print("The customer did not buy this product.")
prod_name = input("Product Name: ")
price = 0
for lol in info_list:
if prod_name in lol:
x = info_list.index(lol)
if year1 <= year_list[x] <= year2:
price += float(price_list[x])
if prod_name in product_list:
print("Customer spent "+str(price)+" for "+prod_name+ " in years "+str(interval)+".")