We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Write Python codes to develop a product recording system. It should allow the user to type product names one by one until he/she enters an empty product name. Display the entered product names and quantities so that each line is formatted as “-‐-‐-‐[product name]: [quantity].” For example, a user types ‘beef’, ‘beef’, ‘milk’, ‘steak’, ‘tomato’, ‘potato’, ‘milk’, tomato’, ‘potato’, ‘beef’. Your program should display at the end:
The products you entered and quantities are:
-‐-‐-‐ beef: 3
-‐-‐-‐ milk: 2
-‐-‐-‐ steak: 1
-‐-‐-‐ tomato: 2
-‐-‐-‐ potato: 2
Note: the order of the product names does not matter.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Say "Hello, World!" With Python
You are viewing a single comment's thread. Return to all comments →
Can someone help with this practice exercise?
Write Python codes to develop a product recording system. It should allow the user to type product names one by one until he/she enters an empty product name. Display the entered product names and quantities so that each line is formatted as “-‐-‐-‐[product name]: [quantity].” For example, a user types ‘beef’, ‘beef’, ‘milk’, ‘steak’, ‘tomato’, ‘potato’, ‘milk’, tomato’, ‘potato’, ‘beef’. Your program should display at the end:
The products you entered and quantities are: -‐-‐-‐ beef: 3 -‐-‐-‐ milk: 2 -‐-‐-‐ steak: 1 -‐-‐-‐ tomato: 2 -‐-‐-‐ potato: 2
Note: the order of the product names does not matter.