Unnnamedddd

Untitled

Jan 20th, 2021
760
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Deque:
  2.     def __init__(self, deque):
  3.         self.deque = deque
  4.  
  5.     def push_back(self, elem):
  6.         self.deque.append(elem)
  7.  
  8.     def pop_back(self):
  9.         self.deque.pop(-1)
  10.  
  11.     def push_front(self, elem):
  12.         self.deque.insert(0, elem)
  13.  
  14.     def pop_front(self):
  15.         self.deque.pop(0)
  16.  
  17.     def show(self) -> list:
  18.         return self.deque
  19.  
  20.     def size(self) -> int:
  21.         return len(self.deque)
  22.  
  23.     def empty(self) -> bool:
  24.         return len(self.deque) == 0
  25.  
  26.  
  27. def get_sign(word, char):
  28.     middle = (word.size() - 1) / 2
  29.     index = word.deque.index(char)
  30.     current_char = "мусор"
  31.     if index <= middle:
  32.         while current_char != char:
  33.             current_char = word.deque[0]
  34.             word.pop_front()
  35.             print(current_char)
  36.     else:
  37.         while current_char != char:
  38.             current_char = word.deque[-1]
  39.             word.pop_back()
  40.             print(current_char)
  41.  
  42.  
  43. my_word = Deque(list("Привет"))
  44. get_sign(my_word, "и")
  45.  
RAW Paste Data