If statement not working properly when else added. The else statement prints when the if statement should.
Doesnt work:
variable = 'programming'
for i, word in enumerate(wv.vocab):
if word == variable:
print("Is ready to be measured")
else:
print("text to clean")
#do this
break
The below works showing the term variable is in the model wv.vocab
variable = 'programming'
for i, word in enumerate(wv.vocab):
if word == variable:
print("Is ready to be measured")
#else:
#print("text to clean")
#do this
break
When the variable is changed to something not in the model it does not work.
variable = 'programmings'
for i, word in enumerate(wv.vocab):
if word == variable:
print("Is ready to be measured")
#else:
#print("text to clean")
#do this
break
@VisionN thank you.
for i, word in enumerate(wv.vocab):
if word == variable:
print("Is ready to be measured")
break
else:
print("text to clean")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.