Last active
January 19, 2021 22:57
-
-
Save sojohnnysaid/2aa93c8b562373ad4ab3818002014dc2 to your computer and use it in GitHub Desktop.
python command line arguments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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