Advertisement
MaximTakkaTo

task2

Mar 11th, 2022
620
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.78 KB | None | 0 0
  1. strs = []
  2.  
  3. input_str = ""
  4.  
  5. while input_str != "Конец":
  6.     input_str = input()
  7.     if (input_str != "Конец"):
  8.         strs.append(input_str)
  9. year = input()
  10.  
  11. search_strs = []
  12.  
  13. for s in strs:
  14.     split_s = str.split(s, ", ")
  15.     if split_s[1] == year:
  16.         search_strs.append(split_s[0] + " (материал - " + split_s[2] + ")")
  17.  
  18. output = ""
  19. if (len(search_strs) == 0):
  20.     output = "В этот год никто не покупал волшебные палочки"
  21. else:
  22.     output = "В " + year + " году волшебную палочку купили: "
  23.     i = 0
  24.     for s in search_strs:
  25.         output += s
  26.         i += 1
  27.         if (i != len(search_strs)):
  28.             output += ", "
  29.         else:
  30.             output += '.'
  31. print(output)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement