Advertisement
CR7CR7

Title search

May 8th, 2022
872
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. title = input()
  2. N = int(input())
  3. L = []
  4. Del = []
  5. for i in range(N):
  6.     L.append(input())
  7.  
  8. for word in L:
  9.     check = False
  10.     place = 0
  11.     Del = []
  12.     for letter in word:
  13.         if title.find(letter, place) >= 0:
  14.             place = title.find(letter, place)
  15.             Del.append(place)
  16.             place += 1  
  17.         else:
  18.             break
  19.     else:
  20.         check = True
  21.     if check:
  22.         new_title = list(title)
  23.         for j in range(len(Del) - 1, -1, -1):
  24.             new_title.pop(Del[j])
  25.         title = ''
  26.         for i in new_title:
  27.             title += i
  28.         print(title)
  29.     else:
  30.         print("No such title found!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement