"""
    Pick a word from /usr/share/dict/words
"""

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)
"""
    Pick a word from /usr/share/dict/words
"""

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
