Level = 4
Name = "Mike"
Form = None
if Level == 5 or Name in ['James','Chris','Alex'] or (Name in ['John','Mike'] and Form):
The above code does exactly what I want it to do, but I can't figure out how to do the opposite:
eg
if Level != 5 and Name not in ['James','Chris','Alex'] and (Name not in ['John','Mike'] and Form):
As close as I got but does not work the same.
How about clubbing everything in parenthesis and just use not
in the beginning. That way, you don't need to reverse any operator.
if not (Level == 5 or Name in ['James','Chris','Alex'] or (Name in ['John','Mike'] and Form)):
Your question is a bit vague, As far as i understand it should be pretty simple,
if not (Level == 5 or Name in ['James','Chris','Alex'] or (Name in ['John','Mike'] and Form)):
another easy way would be to do something like this
if Level == 5 or Name in ['James','Chris','Alex'] or (Name in ['John','Mike'] and Form):
pass
else:
# your code here
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.