I'm new to coding so I don't really understand the logic behind some of this stuff. I do understand a basic if statement. Could someone please eli5 the logic below and why it doesn't work?
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("mode", help="Use encode/decode")
args = parser.parse_args()
mode = args.mode
encode = 'encode'
decode = 'decode'
Now for my if statements. This one works fine but I want the inverse.
if mode == encode or mode == decode:
print("Mode is supported!")
This one works fine and figured out after some searching
if not (mode == encode or mode == decode):
print("Mode isn't supported")
exit()
This was my first choice because I thought it should operate like the first one but opposite which it doesn't.
if mode != encode or mode != decode:
print("Mode isn't supported")
exit()
Aucun commentaire:
Enregistrer un commentaire