title: How to parse user input for arguments? Python
body: <p>My issue is located in the middle section of the code.</p>
  <pre><code>
  from itertools import product
  import sys
  import time
  
  color = [&quot;red&quot;, &quot;orange&quot;, &quot;yellow&quot;, &quot;blue&quot;, &quot;green&quot;, &quot;indigo&quot;, &quot;violet&quot;,
           &quot;pink&quot;, &quot;magenta&quot;, &quot;grey&quot;, &quot;white&quot;, &quot;black&quot;, &quot;brown&quot;, &quot;tan&quot;,
           &quot;gold&quot;, &quot;silver&quot;]
  
  sport = [&quot;soccer&quot;, &quot;football&quot;, &quot;cricket&quot;, &quot;baseball&quot;, &quot;softball&quot;,
           &quot;hockey&quot;, &quot;tennis&quot;]
  
  adj = [&quot;all&quot;, &quot;one&quot;, &quot;other&quot;, &quot;this&quot;, &quot;that&quot;, &quot;more&quot;,
         &quot;most&quot;, &quot;first&quot;, &quot;new&quot;, &quot;newer&quot;, &quot;newest&quot;, &quot;good&quot;,
         &quot;better&quot;, &quot;best&quot;, &quot;last&quot;, &quot;own&quot;, &quot;same&quot;, &quot;old&quot;,
         &quot;older&quot;, &quot;elder&quot;, &quot;eldest&quot;, &quot;oldest&quot;, &quot;little&quot;
         ]
  animal =[&quot;cat&quot;, &quot;kitty&quot;, &quot;kitten&quot;, &quot;dog&quot;, &quot;doggy&quot;, &quot;puppy&quot;,  &quot;elephant&quot;,
            &quot;serval&quot;, &quot;ocelot&quot;, &quot;giraffe&quot;,&quot;caracal&quot;, &quot;saiga&quot;, &quot;viper&quot;,
            &quot;macaw&quot;, &quot;bear&quot;, &quot;panda&quot;, &quot;parrot&quot;, &quot;kia&quot;, &quot;gazel&quot;, &quot;hiyena&quot;,
            &quot;bird&quot;, &quot;eagle&quot;, &quot;margay&quot;, &quot;ferret&quot;, &quot;tapir&quot;, &quot;agouti&quot;, &quot;puffin&quot;,
            &quot;baboon&quot;, &quot;mandrill&quot;, &quot;vulture&quot;, &quot;lemur&quot;, &quot;langur&quot;, &quot;ringtail&quot;,
            &quot;buzzard&quot;, &quot;albatross&quot;, &quot;seahorse&quot;, &quot;cockroach&quot;, &quot;otter&quot;,
            &quot;racoon&quot;, &quot;quail&quot;, &quot;emu&quot;, &quot;rhea&quot;, &quot;cassowary&quot;, &quot;barracuda&quot;,
            &quot;owl&quot;, &quot;alpaca&quot;, &quot;gemsbok&quot;, &quot;eel&quot;, &quot;cheetah&quot;, &quot;catfish&quot;,
            &quot;pangolin&quot;, &quot;crab&quot;, &quot;bat&quot;, &quot;walrus&quot;, &quot;fox&quot;
            ]
  
  noun = [&quot;number&quot;,&quot;ladder&quot;, &quot;axe&quot;, &quot;account&quot;, &quot;apple&quot;, &quot;house&quot;, &quot;case&quot;, &quot;system&quot;,
           &quot;group&quot;, &quot;party&quot;, &quot;company&quot;, &quot;school&quot;, &quot;fact&quot;, &quot;money&quot;, &quot;point&quot;,
           &quot;state&quot;, &quot;night&quot;, &quot;water&quot;, &quot;thing&quot;, &quot;family&quot;, &quot;head&quot;, &quot;hand&quot;, &quot;order&quot;,
           &quot;home&quot;, &quot;power&quot;, &quot;country&quot;, &quot;council&quot;, &quot;use&quot;, &quot;service&quot;, &quot;room&quot;, &quot;market&quot;,
           &quot;problem&quot;, &quot;court&quot;, &quot;police&quot;, &quot;car&quot;, &quot;vehicle&quot;, &quot;form&quot;, &quot;face&quot;, &quot;education&quot;
          ]
  verb = [&quot;writing&quot;,&quot;riding&quot;
          ]
  
  rng = (1000)
  formnumber2 = ['{:&gt;02d}'.format(i) for i in range(rng)]
  formnumber3 = ['{:&gt;03d}'.format(i) for i in range(rng)]
  formnumber4 = ['{:&gt;04d}'.format(i) for i in range(rng)]
  formnumber5 = ['{:&gt;05d}'.format(i) for i in range(rng)]
  formnumber6 = ['{:&gt;06d}'.format(i) for i in range(rng)]
  formnumber7 = ['{:&gt;07d}'.format(i) for i in range(rng)]
  formnumber8 = ['{:&gt;08d}'.format(i) for i in range(rng)]
  formnumber9 = ['{:&gt;09d}'.format(i) for i in range(rng)]
  
  #def type(str):
   #   for char in str:
    #      time.sleep(.001)
     #     sys.stdout.write(char)
      #    sys.stdout.flush()
  
  #def open_file(_fileName):
   #   rng = input(&quot;Set integer's max(Default=1000): &quot;)
    #  with open(_fileName, 'w') as f_out:
     #     type(&quot;Please wait while I write your file...&quot;)
      #    for c in product(color):
       #       print(''.join(c), file=f_out)
  
  def Cmd():
      print(&quot;LOADING...\n&quot;)
      time.sleep(2)
      print(&quot;Enter the name of the file you'd like to create for your wordlist.\n&quot;)
      print(&quot;If a file with that name already exists, it will be overwritten.\n&quot;)
      print(&quot;Please refrain from using numbers in your filename.\n&quot;)
      fileName = &quot;/wordlists/&quot;+input(&quot;&gt; &quot;)
      &quot;&quot;&quot;numbers = ['{:&gt;03d}'.format(i) for i in range(999)]&quot;&quot;&quot;
      print()
      print(&quot;Please enter the rule arguments in the order you would like to apply them to your wordlist.\n&quot;)
      print()
      print(&quot;Rule args:| color / adjective / animal / noun / verb / number / formnumber |\n&quot;)
      print()
      print(&quot;'number' will write a number as: 1\n&quot;)
      print(&quot;while 'formnumber2' will write as: 01 ; and 'formnumber9' will write as: 000000001\n&quot;)
      print()
      print(&quot;For example:\n&quot;)
      print(&quot;            color, animal, formnumber3 | #1,646,352 words\n&quot;)
      print(&quot;            #Writes things like: redshark001 or greentiger999\n&quot;)
      print(&quot;          or\n&quot;)
      print(&quot;            noun, noun, formnumber2 | #22,498,789 words\n&quot;)
      print(&quot;            #Writes things like: roomservice02 or waterdamage999\n&quot;)
      print(&quot;          or\n&quot;)
      print(&quot;            adj, noun, number | #256,383,360 words\n&quot;)
      print(&quot;            #Writes things like: posionapple2 or ancientpalace123\n&quot;)
      args = input(&quot;&gt; &quot;)
      
      #split = args.split(', ')
      #print(len(split))
  #please ignore this.
      #for lsts args:
       #   rng = input(&quot;Set integer's max(Default=1000): &quot;)
        #  with open(fileName, 'w') as f_out:
         #     type(&quot;Please wait while I write your file...&quot;)
          #    for c in product(args):
           #       print(''.join(c), file=f_out)
              
  </code></pre>
  <p>I need to shorten this lower half
  Do I need a for loop or something?</p>
  <p>I'm not quite sure what I need to do to check the input for arguments.
  I have a feeling its using indexing??? like args[0-4]? maybe?</p>
  <p>As you can see above I've tried and tested a few ideas to no avail.</p>
  <p>VVVV</p>
  <pre><code>    if &quot;color&quot; in args:
          rng = input(&quot;Set integer's max(Default=1000): &quot;)
          with open(fileName, 'w') as f_out:
              type(&quot;Please wait while I write your file...&quot;)
              for c in product(color):
                  print(''.join(c), file=f_out)
      
      if &quot;color, animal, formnumber3&quot; in args:
          rng = input(&quot;Set integer's max(Default=1000): &quot;)
          with open(fileName, 'w') as f_out:
              type(&quot;Please wait while I write your file...&quot;)
              for c in product(color, animal, formnumber3):
                  print(''.join(c), file=f_out)
                  
      if &quot;color, animal, formnumber2&quot; in args:
          rng = input(&quot;Set integer's max(Default=1000): &quot;)
          with open(fileName, 'w') as f_out:
              type(&quot;Please wait while I write your file...&quot;)
              for c in product(color, animal, formnumber2):
                  print(''.join(c), file=f_out)
  
      if &quot;color, animal, number&quot; in args:
          rng = input(&quot;Set integer's max(Default=1000): &quot;)
          with open(fileName, 'w') as f_out:
              type(&quot;Please wait while I write your file...&quot;)
              for c in product(color, animal, number):
                  print(''.join(c), file=f_out)
  
      if &quot;formnumber9&quot; in args:
          rang = input(&quot;Set integer's max(Default=1000): &quot;)
          rng = rang
          with open(fileName, 'w') as f_out:
              type(&quot;Please wait while I write your file...&quot;)
              for c in product(formnumber9):
                  print(''.join(c), file=f_out)
  
      if &quot;noun, noun, formnumber2&quot; in args:
          rng = input(&quot;Set integer's max(Default=1000): &quot;)
          with open(fileName, 'w') as f_out:
              type(&quot;Please wait while I write your file...&quot;)
              for c in product(noun, noun, formnumber2):
                  print(''.join(c), file=f_out)
  
      if &quot;adj, noun, formnumber2&quot; in args:
          rng = input(&quot;Set integer's max(Default=1000): &quot;)
          with open(fileName, 'w') as f_out:
              type(&quot;Please wait while I write your file...&quot;)
              for c in product(adj, noun, formnumber2):
                  print(''.join(c), file=f_out)
  
      if &quot;adj, noun, formnumber3&quot; in args:
          rng = input(&quot;Set integer's max(Default=1000): &quot;)
          with open(fileName, 'w') as f_out:
              type(&quot;Please wait while I write your file...&quot;)
              for c in product(adj, noun, formnumber3):
                  print(''.join(c), file=f_out)
  
                  
  
      type(&quot;All finished!\n&quot;)
      time.sleep(1)
      type(&quot;Killing this program...\n&quot;)
      time.sleep(1)
      quit()
  
  Cmd()
  </code></pre>
  <p>Any help is appreciated.</p>