Write a function `getDrinkByProfession`/`get_drink_by_profession()` that receives as input parameter a string, and produces outputs according to the following table:




Input
Output


"Jabroni"
"Patron Tequila"


"School Counselor"
"Anything with Alcohol"


 "Programmer"
 "Hipster Craft Beer"


 "Bike Gang Member"
"Moonshine" 


 "Politician"
"Your tax dollars" 


 "Rapper"
"Cristal" 


 *anything else* 
"Beer" 





Note: *anything else* is the default case: if the input to the function is not any of the values in the table, then the return value should be "Beer."

Make sure you cover the cases where certain words do not show up with correct capitalization. For example, getDrinkByProfession("pOLitiCIaN") should still return "Your tax dollars".

Difficulty: EASY
Tags: String algorithms

Fundamentals

Starter code:
def get_drink_by_profession(param):
	

Solutions:
d = {'jabroni': 'Patron Tequila', 'school counselor': 'Anything with Alcohol', 'programmer': 'Hipster Craft Beer', 'bike gang member': 'Moonshine', 'politician': 'Your tax dollars', 'rapper': 'Cristal'}

def get_drink_by_profession(s):
	return d.get(s.lower(), 'Beer')


def get_drink_by_profession(param):
	return {'Jabroni': 'Patron Tequila', 'School Counselor': 'Anything with Alcohol', 'Programmer': 'Hipster Craft Beer', 'Bike Gang Member': 'Moonshine', 'Politician': 'Your tax dollars', 'Rapper': 'Cristal'}.get(param.title(), 'Beer')


def get_drink_by_profession(param):
	d = {'Jabroni': 'Patron Tequila', 'School Counselor': 'Anything with Alcohol', 'Programmer': 'Hipster Craft Beer', 'Bike Gang Member': 'Moonshine', 'Politician': 'Your tax dollars', 'Rapper': 'Cristal'}
	if param.title() in d:
		return d[param.title()]
	else:
		return 'Beer'


def get_drink_by_profession(param):
	newparam = param.lower()
	if newparam == 'jabroni':
		return 'Patron Tequila'
	elif newparam == 'school counselor':
		return 'Anything with Alcohol'
	elif newparam == 'programmer':
		return 'Hipster Craft Beer'
	elif newparam == 'bike gang member':
		return 'Moonshine'
	elif newparam == 'politician':
		return 'Your tax dollars'
	elif newparam == 'rapper':
		return 'Cristal'
	else:
		return 'Beer'


get_drink_by_profession = lambda p: {'Jabroni': 'Patron Tequila', 'School Counselor': 'Anything with Alcohol', 'Programmer': 'Hipster Craft Beer', 'Bike Gang Member': 'Moonshine', 'Politician': 'Your tax dollars', 'Rapper': 'Cristal'}.get(p.title(), 'Beer')


def get_drink_by_profession(param):
	Drinks = {'jabroni': 'Patron Tequila', 'school counselor': 'Anything with Alcohol', 'programmer': 'Hipster Craft Beer', 'bike gang member': 'Moonshine', 'politician': 'Your tax dollars', 'rapper': 'Cristal'}
	profession = param.lower()
	for key in Drinks:
		if key == profession:
			return Drinks[key]
	return 'Beer'


get_drink_by_profession = lambda param: {'jabroni': 'Patron Tequila', 'school counselor': 'Anything with Alcohol', 'programmer': 'Hipster Craft Beer', 'bike gang member': 'Moonshine', 'politician': 'Your tax dollars', 'rapper': 'Cristal'}.get(param.lower(), 'Beer')


def get_drink_by_profession(param):
	param = param.lower().title()
	L = ['Jabroni', 'School Counselor', 'Programmer', 'Bike Gang Member', 'Politician', 'Rapper']
	L1 = ['Patron Tequila', 'Anything with Alcohol', 'Hipster Craft Beer', 'Moonshine', 'Your tax dollars', 'Cristal']
	if param in L:
		n = L.index(param)
		return L1[n]
	else:
		return 'Beer'


def get_drink_by_profession(param):
	drinkList = {'jabroni': 'Patron Tequila', 'school counselor': 'Anything with Alcohol', 'programmer': 'Hipster Craft Beer', 'bike gang member': 'Moonshine', 'politician': 'Your tax dollars', 'rapper': 'Cristal'}
	return drinkList[param.lower()] if param.lower() in list(drinkList.keys()) else 'Beer'


KNOWN_DRINK_PREFERENCES = {'zaphod beeblebrox': 'Intergalactic Gargle-Blaster', 'school counselor': 'Anything with Alcohol', 'programmer': 'Hipster Craft Beer', 'politician': 'Your tax dollars', 'jabroni': 'Patron Tequila', 'bike gang member': 'Moonshine', 'rapper': 'Cristal', 'nero': 'Wine'}
get_drink_by_profession = lambda p: KNOWN_DRINK_PREFERENCES.get(p.lower(), 'Beer')


def get_drink_by_profession(param):
	drinks = {'Jabroni': 'Patron Tequila', 'School Counselor': 'Anything with Alcohol', 'Programmer': 'Hipster Craft Beer', 'Bike Gang Member': 'Moonshine', 'Politician': 'Your tax dollars', 'Rapper': 'Cristal'}
	try:
		answer = drinks[param.title()]
	except:
		answer = 'Beer'
	return answer


def get_drink_by_profession(param):
	dict = {'Jabroni': 'Patron Tequila', 'School counselor': 'Anything with Alcohol', 'Programmer': 'Hipster Craft Beer', 'Bike gang member': 'Moonshine', 'Politician': 'Your tax dollars', 'Rapper': 'Cristal'}
	param = param.capitalize()
	if param in dict:
		return dict[param]
	return 'Beer'


thisdict = {'Jabroni': 'Patron Tequila', 'School Counselor': 'Anything with Alcohol', 'Programmer': 'Hipster Craft Beer', 'Bike Gang Member': 'Moonshine', 'Politician': 'Your tax dollars', 'Rapper': 'Cristal'}

def get_drink_by_profession(param):
	formatted = param.title()
	drink = 'Beer'
	if formatted in thisdict:
		drink = thisdict.get(formatted)
	return drink


def get_drink_by_profession(param):
	p = param.lower()
	bartender = {'jabroni': 'Patron Tequila', 'school counselor': 'Anything with Alcohol', 'programmer': 'Hipster Craft Beer', 'bike gang member': 'Moonshine', 'politician': 'Your tax dollars', 'rapper': 'Cristal', 'anything else': 'Beer'}
	if p in bartender:
		return bartender[p]
	else:
		return 'Beer'


def get_drink_by_profession(param):
	jobName = param.upper()
	if jobName == 'JABRONI':
		return 'Patron Tequila'
	elif jobName == 'SCHOOL COUNSELOR':
		return 'Anything with Alcohol'
	elif jobName == 'PROGRAMMER':
		return 'Hipster Craft Beer'
	elif jobName == 'BIKE GANG MEMBER':
		return 'Moonshine'
	elif jobName == 'POLITICIAN':
		return 'Your tax dollars'
	elif jobName == 'RAPPER':
		return 'Cristal'
	else:
		return 'Beer'