Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def sell():
- global base
- global magazine_base
- load_data()
- XD=1
- W1=0
- XD2=1
- W2=0
- while(XD1==1):
- name = raw_input('Name of the product: ')
- is_new_entry = True
- while(XD2==1 OR XD1==1):
- for entry in base:
- if name.lower() == entry['name'].lower():
- is_new_entry = False
- sp=float(entry['price'])
- quantity = raw_input('Quantity to sell: ')
- a=entry['quantity']
- if int(quantity) < entry['quantity']:
- entry['quantity'] -= int(quantity)
- print '%s' % quantity, "of %s" % entry['name'], 'was sold for ' '%s' % float(sp*int(quantity)), 'PLN'
- magazine_base['base'] = base
- magazine_base.close()
- load_data()
- elif int(quantity) == int(a):
- print '%s' % quantity, "of %s" % entry['name'], 'was sold for ' '%s' % float(sp*int(quantity)), 'PLN'
- print "%s" % entry['name'], 'removed from the list'
- del base[base.index(entry)]
- magazine_base['base'] = base
- magazine_base.close()
- else:
- print 'Not enough in magazine'
- W2=0;
- if is_new_entry:
- print 'Product is not in magazine'
- W1=0
- magazine_base['base'] = base
- magazine_base.close()
- if W1==1:
- XD1=0
- if W2==1:
- XD2=0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement