I'm trying to do something like scrabble solver.
letters = ['s','w','r','a']
line_of_dic= ['s','w','r','a','a']
# printing original lists
print("Original list : " + str(line_of_dic))
print("Original sub list : " + str(letters))
# using all() to
# check subset of list
flag = 0
if (all(x in line_of_dic for x in letters)):
flag = 1
# printing result
if (flag):
print("Yes, the word can be created")
else:
print("No, the word cant be.")
This is the part of code that I'm unable to repair, word can't be created, but it prints yes. Is it possible to check if all the letters are in line_of_dic
, but if elements are doubled or tripled to check this? Also, is it possible to do without fancy libraries?