Python Fundamentals - 04. Exam Shopping from Dictionaries - Exercises
Здравейте, колеги!
Моля споделете решение на 04. Exam Shopping from Dictionaries - Exercises, защото вече си скубя косите.
Благодаря!
Здравейте, колеги!
Моля споделете решение на 04. Exam Shopping from Dictionaries - Exercises, защото вече си скубя косите.
Благодаря!
Здравейте отново!
След почивка с няколко други задачи все пак я реших - 100/ 100!!!
Колежке, ще може ли да и пуснеш решението, че нещо накрая ме препъна и мен, с това объркано условие...
Благодаря предварително!
https://github.com/bMedarski/SoftUni/blob/master/Python/Fundamentals/Dictionaries%20and%20Functional%20Programming/06.%20Exam%20Shopping.py
result = {} product = '' quantity = 0 input_row = input() while input_row != "shopping time": input_data = input_row.split(' ') product = input_data[1] quantity = int(input_data[2]) if product in result: result[product] += quantity else: result[product] = quantity input_row = input() input_row = input() while input_row != "exam time": input_data = input_row.split(' ') product = input_data[1] quantity = int(input_data[2]) if product in result: if result[product] <= 0: print("{0} out of stock".format(product)) else: result[product] -= quantity if result[product] < 0: result[product] = 0 else: print("{0} doesn't exist".format(product)) input_row = input() for key in result: if result[key] != 0: print("{0} -> {1}".format(key, result[key]))