|
@@ -0,0 +1,21 @@
|
|
|
+#!/usr/bin/python
|
|
|
+
|
|
|
+cart = [
|
|
|
+ {'id': 1, 'name': 'Product1', 'price': '2000', 'quantity': 0},
|
|
|
+ {'id': 2, 'name': 'Product2', 'price': '3000', 'quantity': 0},
|
|
|
+ {'id': 3, 'name': 'Product3', 'price': '4000', 'quantity': 0}
|
|
|
+]
|
|
|
+
|
|
|
+print cart
|
|
|
+
|
|
|
+readed = {'id': 1, 'name': 'Product1', 'price': '2000', 'quantity': 0}
|
|
|
+
|
|
|
+print readed
|
|
|
+
|
|
|
+index = cart.index(readed)
|
|
|
+
|
|
|
+print index
|
|
|
+
|
|
|
+cart[index]['quantity'] += 1
|
|
|
+
|
|
|
+print cart
|