Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- num = int(input())
- word = input()
- lst = []
- filtered = []
- for i in range(num):
- text = input()
- filtered.append(text) if word in text else lst.append(text)
- print(f'{lst}\n{filtered}')
- Или:
- num = int(input())
- word = input()
- lst = []
- for i in range(num):
- lst.append(input())
- print(f'{lst}\n{[x for x in lst if word in x]}') # print(f'{lst}\n{list(filter(lambda x: word in x, lst))}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement