Skip to content

Instantly share code, notes, and snippets.

@sojohnnysaid
Last active January 19, 2021 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sojohnnysaid/2aa93c8b562373ad4ab3818002014dc2 to your computer and use it in GitHub Desktop.
Save sojohnnysaid/2aa93c8b562373ad4ab3818002014dc2 to your computer and use it in GitHub Desktop.
python command line arguments
import sys
def main():
if len(sys.argv) == 2:
print(f"the program name is {sys.argv[0]}")
print(f"hello, {sys.argv[1]}")
for eachArg in sys.argv:
for eachChar in eachArg:
print(eachChar)
print() # a line break between each vertical word
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment