Skip to content

Instantly share code, notes, and snippets.

@tatterdemalion
Last active October 15, 2016 09:58
Show Gist options
  • Save tatterdemalion/5e87133e1e44eb4be05b15d605aa74b7 to your computer and use it in GitHub Desktop.
Save tatterdemalion/5e87133e1e44eb4be05b15d605aa74b7 to your computer and use it in GitHub Desktop.
My contribution to a program
"""My contribution to your program."""
import os
try:
input = raw_input # For backwards compatibility
except NameError:
pass
output = """
Welcome Lazy User
{}
[Q]Quit
"""
mapping = (
{"command": "chromium-browser", "name": "Chromium Browser"},
{"command": "firefox", "name": "Firefox Web Browser"},
{"command": "spotify", "name": "Spotify Player"},)
options = ["[%s]%s" % (c, i["name"]) for c, i in enumerate(mapping)]
while True:
print(output.format("\n".join(options)))
myinput = input("Choose What You Want: ")
if myinput.upper() == "Q":
break
myinput = int(myinput)
if not myinput or myinput >= len(mapping):
print("You gotta enter a valid option")
else:
os.system(mapping[myinput]["command"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment