Let's use a dictionary to declare items={" in the form of a product:value":650, "milk":1100, "cola":1200, "can coffee":500, "snack":700}. Use the while statement to input the product indefinitely and output the sum of the values for the product. When an empty string is entered by pressing Enter without any input, it stops infinite repetition and outputs the total. And if it's a product that's not entered into the product, I'd like to print it as unregistered Can you help me? I don't know how to code. Help me.
items={"if":650, "milk":1100, "cola":1200, "can coffee":500, "snack":700}
it=input ('product:')
while true:
s=float(it)
for index, value in enumerate(items):
s=s+items
print('[%s:%d]>%d'%(it, items[it], s))
I've come this far, but I'm not making any progress.
python
items={"if":650, "milk":1100, "cola":1200, "can coffee":500, "snack":700}
sum = 0;
while True:
it = input ('Please enter the product name :')
if it == "":
break
get_item = items.get(it,'none');
if(get_item == 'none'):
print ('This product is not registered')
else :
sum += items.get(it)
print('total' +str(sum)+'circle.')
I might get it wrong because I'm not a Python user, The value you want comes out
© 2024 OneMinuteCode. All rights reserved.