Last active
October 15, 2016 09:58
-
-
Save tatterdemalion/5e87133e1e44eb4be05b15d605aa74b7 to your computer and use it in GitHub Desktop.
My contribution to a program
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""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