Advertisement
Falexom

Untitled

Jan 18th, 2023 (edited)
1,083
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.80 KB | None | 0 0
  1. class Storage:
  2.     compose = []
  3.  
  4. stor = Storage()
  5.  
  6. class ValidationError:
  7.     pass
  8.  
  9.  
  10. def add(a,b):
  11.     if not "," in b:
  12.         raise ValidationError
  13.     dct = {a: b}
  14.     stor.compose.append(dct)
  15.  
  16. def search(a):
  17.     temp = {}
  18.     buf = "a"
  19.     print(a)
  20.     for i in stor.compose:
  21.         for j in i.keys():
  22.             if j == a:
  23.                 buf = j
  24.                 temp = i
  25.     print(temp)
  26.     numb = temp[buf]
  27.     count = 0
  28.     numb = numb.split(",")
  29.     count += int(numb[0]) * 60 + int(numb[1])
  30.     sec = f"0.{numb[2]}"
  31.     count += float(sec)
  32.     temp[buf] = count
  33.     return temp
  34.  
  35. add("Лунная соната", "5,30,55")
  36. add("В пещере горного короля", "7,20,31")
  37.  
  38. print(stor.compose)
  39.  
  40. print(search("В пещере горного короля"))
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement