So, I'm working on a python project (I'm a beginner), but I'm having trouble comparing a list to words in a text file. It's for a program that should unscramble words.
your_chars = input("Input characters:")
complete_list = []
final_lst = []
for current in range(len(your_chars)):
a = [i for i in your_chars]
for y in range(current):
a = [x + i for i in your_chars for x in a]
complete_list = complete_list+a
with open("P:/words.txt", "r") as file:
for i in complete_list
for x in file:
final_lst.append(x)
print(final_lst)
I think it should work, but obviously it's not very efficient (especially the last three lines), but I can't think of another way to write it.
Ex:
input: yhe
output: hey
Any tips?
complete_listdoing here? It looks like you repeat the lines a large number of times.with open(..) as fileandfor line in file.complete_liast, but doesn't usei. That just a purposeless repeat.