Vérifiez si Argv existe Python

# First, make sure that you import "sys"
import sys

# Next, run a simple conditonal statement to check if argv exists
if len(sys.argv) > 1:
    result = sys.argv[1]
else:
    result = False

# Finally, you can use the result from the above test and run further code accordingly
if result == False:
    print("argv DOES NOT exist!")
else:
  print("argv exists!")
  if result == "foo":
      # some code here, which executes when argv is "foo"
      print("Foo!")
  elif result == "bar":
      # some code here, which executes when argv is "bar"
      print("Bar")
  else:
      # some code here, which executes as the default, if the argument value is niether "foo", nor "bar"
      print("Baz")
      
# Happy coding, my homies <3
CoderHomie