[challenge] Where to buy - Shopping at sololearn | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

[challenge] Where to buy - Shopping at sololearn

Given a list of shops each with different products. Enter a product . Output the shops who have the product. This is no homework i am not a student (-; shops =[ {'walmart' :[soap,shoe,sweets]}, {'pcking':[keyboard, monitor,sweets]}, {'dodo':[soap,sweets]} ] user enters : soap output: walmart, dodo

21st Oct 2017, 11:55 AM
Oma Falk
Oma Falk - avatar
7 Answers
+ 4
Please provide a sample input and output case, for proper understanding. What all do you need as input? Test cases, then number of shops? Or just the list of products and we determine the number ourselves? In output, do we need to display the shop number or is there some other format?
21st Oct 2017, 8:11 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
+ 4
@kinshuk I added an example.
21st Oct 2017, 8:22 AM
Oma Falk
Oma Falk - avatar
+ 4
@Kinshuk yes that it is. Indeed the point is to find a good datastrucure. you can do it as simple or ellaborated as you want.
21st Oct 2017, 8:32 AM
Oma Falk
Oma Falk - avatar
+ 4
Here is my Python example with dictionary as data structure https://code.sololearn.com/cd8Ku62qOZFx
21st Oct 2017, 11:56 AM
Oma Falk
Oma Falk - avatar
+ 3
So, the data of the shop products is entered before compilation?
21st Oct 2017, 8:23 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
21st Oct 2017, 9:57 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
+ 2
heres a self generating...shop...things tht can be bought....a random thing....corresponding shops to get it... ### EACH TIME U RUN IT...U GET ALL DIFFERENT OUTCOMES### https://code.sololearn.com/cR6Qg9O9AFtW/?ref=app
22nd Oct 2017, 5:39 AM
sayan chandra
sayan chandra - avatar