Advertisement
horozov86

Flowers Finder

Jun 14th, 2023 (edited)
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. from collections import deque
  2.  
  3. vowels = deque(x for x in input().split())
  4. consonants = [x for x in input().split()]
  5.  
  6. searched_words = ['rose', 'tulip', 'lotus', 'daffodil']
  7. found_word = set()
  8.  
  9. while True:
  10.     if len(vowels) == 0:
  11.         break
  12.     if len(consonants) == 0:
  13.         break
  14.    
  15.     first_vowel = vowels.popleft()
  16.     last_consonant = consonants.pop()
  17.    
  18.     for word in searched_words:
  19.         for letter in word:
  20.             if first_vowel == letter:
  21.                 found_word.add(letter)
  22.            
  23.             if last_consonant == letter:
  24.                 found_word.add(letter)
  25.            
  26. print(found_word)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement