The commandline argument check in roster.py:

A bit strange, I find whatever I am doing I can't get this error message to print, the function will shut down alright, but no error message, I have tried all ways of putting this into my code that I know of, rest of code works great after intention otherwise, however if I get my errormessage printing, it will just print that, even with correct usage. Stupidly I am actually stumped on this part. I don't understand why it doesn't work, can anyone explain? Hopefully from the "no question is too stupid" mentality, haha.

if len(argv) != 2:
     if argv[1] != "Gryffindor" or argv[1] != "Ravenclaw" or argv[1] != "Hufflepuff" or argv[1] != "Slytherin":
        print("Usage: python roster.py house")

1 Answer 1


That's because of your parent if statement that says if len(argv) != 2 if you're going to check if the argv[1] is a valid argument then the length of argv must be 2. That's why that part of your code will never run, just move it outside the parent if.

  • thanks, I really felt like I had tried everything, crazy how you can stare yourself blind on the small stuff.
    – HoopsLoops
    Jun 8, 2020 at 4:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .