Commit a3dc1170 by likorn

Upload New File

parent 3b50aa06
Showing with 36 additions and 0 deletions
import random
stores = [None] * 3
stores_name = ['Happy Lime', 'Unreleased', 'Kristina']
for num in range(0, len(stores_name)):
print('\nFill ' + stores_name[num] + ' store')
items = []
print("Enter the item's name, the price will be generated automatically")
for x in range(0, 5):
item_name = input()
item = {'item_name': item_name, 'item_price': random.randrange(1, 20)}
items.append(item)
store = {'store_name': stores_name[num], 'items': items}
stores[num] = store
cheap_items = []
for x in range(0, len(stores)):
for y in range(0, 5):
if stores[x]['items'][y]['item_price'] < 10:
item = stores[x]['items'][y]
cheap_item = {'price': item['item_price'], 'name': item['item_name'], 'store': stores[x]['store_name']}
cheap_items.append(cheap_item)
for i in range(1, len(cheap_items)):
j = i - 1
key = cheap_items[i]['price']
while (cheap_items[j]['price'] > key) and (j >= 0):
cheap_items[j + 1]['price'] = cheap_items[j]['price']
cheap_items[j + 1]['name'] = cheap_items[j]['name']
cheap_items[j + 1]['store'] = cheap_items[j]['store']
j -= 1
cheap_items[j + 1]['price'] = key
for m in range(0, len(cheap_items)):
print(cheap_items[m]['name'] + ' from ' + cheap_items[m]['store'] + ' store costs '
+ str(cheap_items[m]['price']) + ' euros')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment