- 2
Can anyone help me making grocery store atleast 4 products greetings customer ,ask customer name and what he wants please help
Without using any modules and make in with dictionary python
6 Antworten
+ 4
next-generation captain
Here is the second part showing how to call dictionary items within another dictionary.
I have also included a section showing how to add separate items to a total bill.
# Your dictionary
product ={
'chips': {'lays':20,
'taka tak':30,
'uncle chips':15},
'biscuit':{'oreo':40,
'parle':10,
'dark fantasy':50},
'chocolate':{'kit kat':50,
'dairy milk':40,
'munch':10},
'milk':{'gyan milk':30,
'amul milk':40,
'parag':27}
}
# Now to call your products
item1 = product['chips']['taka tak']
print(item1)
# or if you will to add multiple items
total = 0
total += product['chips']['taka tak']
total += product['chocolate']['munch']
total += product['milk']['amul milk']
print(total)
+ 3
next-generation captain
Take the time to review the way you presented your code, compared to how I presented it back.
Breaking your code into sections makes it much easier to read and understand.
You had constructed most of your code well, but it was very difficult to debug because of the presentation.
Help yourself in the future by taking the time to lay out your code clearly.
Your teacher will thank you
+ 2
next-generation captain
Here is the first part dressed up a bit.
Coding was good, just a few grammar errors.
Looking at the next part now to see if I can understand it
def customer(customer):
if customer:
print('Nice to meet you '+ str(customer))
else:
print("Welcome to our store sir.")
return
if __name__ == '__main__':
customer_name=input("Hello sir. Welcome to our Store.\nWhat's your name sir?\n")
customer(customer_name)
+ 1
Thanks a lot brother
0
def customer(customer):
if customer:
print ((' nice to meet you '+ str(customer)))
else:
print(" welcome to our store sir")
return
if __name__ == '__main__':
customer_name=input("Hello sir Welcome to our Store\n , Whats your Name sir: ")
customer(customer_name)
product ={"chips":{'lays':20,'taka tak':30,'uncle chips':15} ,'biscuit': {'oreo':40,'parle':10,'dark fantasy':50},'chocolate': {'kit kat':50,'dairy milk':40,'munch':10},'milk': {'gyan milk':30, 'amul milk':40,'parag':27}}
aa=(product['chips']['lays','taka tak','uncle chips'])
#i tried but I have not much time
0
Please help