Skip to content
Advertisement

Tag: sys

execute code only while sys.argv[1] exist

I have this code: and i want execute this piece of code only while sys.argv[1] is exist: if i only start the program without an arguments (python program.py) it’s print this text: I tried “if sys.argv == 1” but doesnt worked. Any solutions? Thanks Answer Now your program will terminate entirely if the user didn’t supply any arguments, rather than

Advertisement