My error appears on this line:
if exclude3 not in Sent:
And it is:
TypeError: 'in <string>' requires string as left operand, not set
My code is:
import string
Word = input("Please give a word from the sentence")
exclude3 = set(string.ascii_letters)
if exclude3 not in Sent:
print("")
elif exclude3 not in Word:
print("")
else:
What is a left operand? What am I doing wrong and is there a simpler way to accomplish what I want? Should I be using something other than in
and what should that be?
exclude3
is not a string
it is a set
.
You try to use the in
operator to check if a set
is contained in another set
which is wrong.
Maybe you meant to write: if Sent not in exclude3
?