import subprocess
import re

programs = input('Separe the programs with a space: ').split()

secure_pattern = '[\w\d]'

for program in programs:

    if not re.match(secure_pattern, program):
        print("Sorry we can't check that program")

        continue

    process = subprocess. run(
        ['which', program], capture_output=True, text=True)

    if process.returncode == 0:
        print(f'The program "{program}" is installed')

        print(f'The location of the binary is: {process.stdout}')
    else:
        print(f'Sorry the {program} is not installed')

        print(process.stderr)

    print('\n')
[((15, 14, 16, 59), 'subprocess.run', 'subprocess.run', (), '', False, 'import subprocess\n'), ((10, 11, 10, 44), 're.match', 're.match', ({(10, 20, 10, 34): 'secure_pattern', (10, 36, 10, 43): 'program'}, {}), '(secure_pattern, program)', False, 'import re\n')]