-
Notifications
You must be signed in to change notification settings - Fork 0
/
test2.py
38 lines (28 loc) · 870 Bytes
/
test2.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
#notes: will do it using oop.
import json
import itertools
with open('products.json') as data_file:
data = json.load(data_file)
products = data['products']
products_temp = []
for index, item in enumerate(products):
products_temp.append(item)
products = products_temp
products_temp = [] # delete the variable
for index, item in enumerate(products):
products_temp.append(item)
products = products_temp
products_temp = None
computers,keyboards = [],[]
for index, item in enumerate(products):
if item ['product_type'] == 'Computer':
computers.append((item['title'],item['options']))
else: pass
if item ['product_type'] == 'Keyboard':
keyboards.append((item['title'],item['options']))
print item
else: pass
for index, item in enumerate(item):
# Do the second step
pass
print computers