33 lines
649 B
Python
33 lines
649 B
Python
|
import sys
|
||
|
|
||
|
try:
|
||
|
words = open("/usr/share/dict/ngerman", "r")
|
||
|
except:
|
||
|
print("/usr/share/dict/ngerman nicht gefunden. Paket \"wngerman\" nicht installiert?")
|
||
|
sys.exit(1)
|
||
|
|
||
|
if len(sys.argv) < 2:
|
||
|
print("Syntax: python3 words.py abc")
|
||
|
sys.exit(1)
|
||
|
|
||
|
letters = []
|
||
|
for letter in sys.argv[1]:
|
||
|
if letter not in letters:
|
||
|
letters.append(letter)
|
||
|
|
||
|
print("Suche nach Wörtern mit folgenden Buchstaben: ", letters, "\n")
|
||
|
|
||
|
matches = []
|
||
|
|
||
|
for word in words:
|
||
|
match = True
|
||
|
for letter in letters:
|
||
|
if letter not in word:
|
||
|
match = False
|
||
|
break
|
||
|
|
||
|
if match:
|
||
|
matches.append(word)
|
||
|
|
||
|
print(matches)
|