The first list contains the items sold by the store, this is a list of strings

computer science

Description

You run a store. You have two lists. The first list contains the

items sold by the store, this is a list of strings. The second list contains

the quantities of these items, this is a float list.

We want to build a dictionary of articles and quantities of articles in this store. The

Dictionary keys are the items, and the values ​​are the respective quantities (from the same index).

Lists are not necessarily the same length.

If the list of items is longer, the dictionary will have zero quantities (= 0) for those items.

If the list of quantities is longer, the dictionary will contain items whose name is

article_inconnu_i, i being an index: i starts from 0 until the number of unknown articles -1

Develop a Python function, called stockMagazin. This function takes as parameter

the two lists described above. The function returns the constructed dictionary.

In the main program, ask the user to enter the elements of each list

separated by commas, invoke the function, and display the result as in the examples.

Please enter the list of items separated by commas:

shirt, t-shirt, pants, dress, socks, shoes

Please enter a list of words separated by commas:

20,15,25,30,10,27

the store's stock is:

{'shirt': '20', 't-shirt': '15', 'pants': '25', 'dress':

'30', 'socks': '10', 'shoes': '27'}

>>>

Please enter the list of items separated by commas:

shirt, t-shirt, pants, dress, socks, shoes

Please enter a list of words separated by commas:

20.15.25.30

the store's stock is:

{'shirt': '20', 't-shirt': '15', 'pants': '25', 'dress':

'30', 'socks': 0, 'shoes': 0}

>>>

Please enter the list of items separated by commas:

shirt, t-shirt

Please enter a list of words separated by commas:

20,15,25,30,10

the store's stock is:

{'shirt': '20', 't-shirt': '15', 'unknown_item0': '25',

'article_inconnu1': '30', 'article_inconnu2': '10'}

Instruction Files

Related Questions in computer science category