Denis McMahon wrote:
On Mon, 19 Jan 2015 16:12:57 -0800, Luke Tomaneng wrote:
I have been having a bit of trouble with the things mentioned in the
title.
I've uploaded a slightly different approach to your code at:
http://www.sined.co.uk/tmp/shop.py.txt
def compute_bill(shopping):
Peter Otten wrote:
Denis McMahon wrote:
sold = {k:0 for k in shopping.keys()}
There is also dict.from_keys()
Sorry, fromkeys():
shopping = {'orange': 5, 'pear': 5, 'banana': 5, 'apple': 4}
dict.fromkeys(shopping, 0)
{'banana': 0, 'orange': 0, 'apple': 0, 'pear': 0}
--
On Wed, 21 Jan 2015 09:43:31 +0100, Peter Otten wrote:
There is also dict.from_keys()
See, I learned something too.
The inner loop is not just inefficient for stock sold in large
quantities,
Agreed, but as for:
it will fail for stock sold by weight, volume etc.
I was trying to stay true
On Mon, 19 Jan 2015 16:12:57 -0800, Luke Tomaneng wrote:
I have been having a bit of trouble with the things mentioned in the
title.
I've uploaded a slightly different approach to your code at:
http://www.sined.co.uk/tmp/shop.py.txt
--
Denis McMahon, denismfmcma...@gmail.com
--
On 2015-01-20 00:12, Luke Tomaneng wrote:
I have been having a bit of trouble with the things mentioned in the title. I
have written the following script for a Codecademy course:
stock = {
banana: 6,
apple: 0,
orange: 32,
pear: 15
}
prices = {
banana: 4,
apple: 2,
On Tue, Jan 20, 2015 at 11:34 AM, Luke Tomaneng luketoman...@gmail.com wrote:
Thanks Chris / Mr. Angelico / whatever you prefer. I attempted to post a
reply to you before but it could not be viewed even after refreshing several
times. You've been helpful.
My pleasure! Your earlier email did
Thanks Chris / Mr. Angelico / whatever you prefer. I attempted to post a reply
to you before but it could not be viewed even after refreshing several times.
You've been helpful.
--
https://mail.python.org/mailman/listinfo/python-list
I have been having a bit of trouble with the things mentioned in the title. I
have written the following script for a Codecademy course:
stock = {
banana: 6,
apple: 0,
orange: 32,
pear: 15
}
prices = {
banana: 4,
apple: 2,
orange: 1.5,
pear: 3
}
def
On Monday, January 19, 2015 at 4:21:58 PM UTC-8, Chris Angelico wrote:
On Tue, Jan 20, 2015 at 11:12 AM, Luke Tomaneng wrote:
def compute_bill(food):
total = 0
for item in food:
if stock[item] 0:
total += prices[item]
stock[item] = stock[item]
On Mon, Jan 19, 2015 at 4:12 PM, Luke Tomaneng luketoman...@gmail.com wrote:
I have been having a bit of trouble with the things mentioned in the title. I
have written the following script for a Codecademy course:
stock = {
banana: 6,
apple: 0,
orange: 32,
pear: 15
}
On Tue, Jan 20, 2015 at 11:12 AM, Luke Tomaneng luketoman...@gmail.com wrote:
def compute_bill(food):
total = 0
for item in food:
if stock[item] 0:
total += prices[item]
stock[item] = stock[item] - 1
return total
Whenever I run this
11 matches
Mail list logo