
import subprocess
from sys import exit
import random

def choose(difficulty):
    (min, max) = difficulty
    cmd = "/usr/bin/grep -E '^.{{{},{}}}$' /usr/share/dict/words".format(min, max)
    obj = subprocess.run(cmd,
                         shell=True,
                         stdout=subprocess.PIPE)
    result = obj.stdout.decode('utf-8').strip().split("\n")
    return random.choice(result)

import subprocess
from sys import exit
import random

def choose(difficulty):
    (min, max) = difficulty
    cmd = "/usr/bin/grep -E '^.{{{},{}}}$' /usr/share/dict/words".format(min, max)
    obj = subprocess.run(cmd,
                         shell=True,
                         stdout=subprocess.PIPE)
    result = obj.stdout.decode('utf-8').strip().split("\n")
    return random.choice(result)


if __name__ == "__main__":
    choose((3, 8))
Add a main guard for testing
Add a main guard for testing

  
  import subprocess
  from sys import exit
  import random
  
  def choose(difficulty):
      (min, max) = difficulty
      cmd = "/usr/bin/grep -E '^.{{{},{}}}$' /usr/share/dict/words".format(min, max)
      obj = subprocess.run(cmd,
                           shell=True,
                           stdout=subprocess.PIPE)
      result = obj.stdout.decode('utf-8').strip().split("\n")
      return random.choice(result)
+ 
+ 
+ if __name__ == "__main__":
+     choose((3, 8))
Add a main guard for testing
## Code Before:

import subprocess
from sys import exit
import random

def choose(difficulty):
    (min, max) = difficulty
    cmd = "/usr/bin/grep -E '^.{{{},{}}}$' /usr/share/dict/words".format(min, max)
    obj = subprocess.run(cmd,
                         shell=True,
                         stdout=subprocess.PIPE)
    result = obj.stdout.decode('utf-8').strip().split("\n")
    return random.choice(result)
## Instruction:
Add a main guard for testing
## Code After:

import subprocess
from sys import exit
import random

def choose(difficulty):
    (min, max) = difficulty
    cmd = "/usr/bin/grep -E '^.{{{},{}}}$' /usr/share/dict/words".format(min, max)
    obj = subprocess.run(cmd,
                         shell=True,
                         stdout=subprocess.PIPE)
    result = obj.stdout.decode('utf-8').strip().split("\n")
    return random.choice(result)


if __name__ == "__main__":
    choose((3, 8))