Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import deque
- flowers = ["rose", "tulip", "lotus", "daffodil"]
- vowels = deque(input().split())
- consonants = input().split()
- found_words = {}
- is_found = False
- while vowels and consonants:
- vow = vowels.popleft()
- cons = consonants.pop()
- for word in flowers:
- if vow in word:
- if word not in found_words:
- found_words[word] = []
- found_words[word].append(vow)
- if set(word) == set(found_words[word]):
- print(f"Word found: {word}")
- is_found = True
- break
- if cons in word:
- if word not in found_words:
- found_words[word] = []
- found_words[word].append(cons)
- if set(word) == set(found_words[word]):
- print(f"Word found: {word}")
- is_found = True
- break
- if is_found:
- break
- if not is_found:
- print("Cannot find any word!")
- if vowels:
- print("Vowels left:", *vowels)
- if consonants:
- print("Consonants left:", *consonants)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement