By using an input as a pattern (which is the reverse of the typical use case), you can easily implement a simple word auto-completion feature!
import re
example_words = ["Python", "Linux", "HHKB", "Pizza", "Ninja"]
pattern = input()
for word in example_words:
if re.match(pattern, word, re.IGNORECASE):
print(word)
Input example
li
Output
Linux
Version: Python 3
Top comments (0)