Reputation: 1
if guess == wordleword.lower():
print('Well Done!\n')
print('You got it right!\n')
print('Point added\n')
points += 1
with open('points.txt', 'w') as e:
e.write(str(points))
print('You now have ' + str(points))
result = "".join(set(guess))
if guess[0] in wordleword:
print(guess.upper()[0] + ' is in the word')
if guess[1] in wordleword:
print(guess.upper()[1] + ' is in the word')
if guess[2] in wordleword:
print(guess.upper()[2] + ' is in the word')
if guess[3] in wordleword:
print(guess.upper()[3] + ' is in the word')
if guess[4] in wordleword:
print(guess.upper()[4] + ' is in the word')
How do I see if any character in result is included in the variable wordleword
, and print to the terminal what letters are included?
Upvotes: -2
Views: 55
Reputation: 5425
You can perform a set intersection
.
w_set = set(wordleword.lower())
g_set = set(guess.lower())
print(sorted(w_set.intersection(g_set)))
Upvotes: 0