I'm learning Python and a bit confused what if not
doing in the below code? I presume if not
is like else
statement. But it turns out I'm wrong. What is the value of if not exists
in this code? Also another naive question, the variable exists
is defined within a for loop, why is it available globally?
import scrabble
import string
for letter in string.ascii_lowercase:
for word in scrabble.wordlist:
exists = False
if letter * 2 in word:
exists = True
break
if not exists:
print(letter)
print(exists) # Globally exists = True