Command Line Arguments in Python

Open the following as this in cmd:

python filename.py argument

from sys import argv

if len(argv) == 2:
    print(f"Hello, {argv[1]}!")
else:
    print("Hello, World!")
    
# to see what is there in argv
for arg in argv:
    print(arg)  

    

Comments

Popular posts from this blog

Quotation marks to wrap an element in HTML

The Basic Structure of a Full-Stack Web App

Unlocking Web Design: A Guide to Mastering CSS Layout Modes