Skip to content

Instantly share code, notes, and snippets.

@GeorgeSeif
Last active September 30, 2019 11:04
Show Gist options
  • Select an option

  • Save GeorgeSeif/1b41fe5c511d1e28116e19776efe1732 to your computer and use it in GitHub Desktop.

Select an option

Save GeorgeSeif/1b41fe5c511d1e28116e19776efe1732 to your computer and use it in GitHub Desktop.
import argparse
parser = argparse.ArgumentParser(description='A tutorial of argparse!')
parser.add_argument("--a", default=1, type=int, help="This is the 'a' variable")
parser.add_argument("--education",
choices=["highschool", "college", "university", "other"],
required=True, type=str, help="Your name")
args = parser.parse_args()
ed = args.education
if ed == "college" or ed == "university":
print("Has degree")
elif ed == "highschool":
print("Finished Highschool")
else:
print("Does not have degree")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment