Advertisement
SimeonTs

SUPyF2 Dictionaries-Lab - 01. Bakery

Oct 23rd, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. """
  2. Dictionaries - Lab
  3. Check your code: https://judge.softuni.bg/Contests/Practice/Index/1736#0
  4.  
  5. SUPyF2 Dictionaries-Lab - 01. Bakery
  6.  
  7. Problem:
  8. This is your first task in your new job.
  9. You were tasked to create a list of the stock in a bakery and you really don't want to fail at you first day at work.
  10. You will receive a single line containing some food (keys) and quantities (values).
  11. They will be separated by a single space (the first element is the key, the second – the value and so on).
  12. Create a dictionary with all the keys and values and print it on the console
  13.  
  14. Examples:
  15. Input:                                  Output:
  16. bread 10 butter 4 sugar 9 jam 12        {'bread': 10, 'butter': 4, 'sugar': 9, 'jam': 12}
  17. """
  18.  
  19. string_to_list = [item for item in input().split()]
  20.  
  21. bakery = {}
  22.  
  23. for key in range(0, len(string_to_list), 2):
  24.     item = string_to_list[key]
  25.     value = int(string_to_list[key + 1])
  26.     bakery[item] = value
  27.  
  28. print(bakery)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement