change false to true python

flag = False
print(flag) # False
flag = not flag
print(flag) # True

Here is what the above code is Doing:
1. We create a variable called flag and set it to True.
2. We print the value of flag.
3. We set flag to the opposite of what it is.
4. We print the value of flag again.

The output of the code is:


The first time we print flag, it is True. The second time we print it, it is False.

You can use the not operator on any value, not just booleans.

Here’s an example: