Created
February 25, 2011 01:29
-
-
Save MarcoPolo/843256 to your computer and use it in GitHub Desktop.
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
def can_we_go_to_bar(people_in_group): | |
able_to_drink = [] | |
underage = [] | |
for i in range(len(people_in_group)): | |
#Add to list if can drink and likes to | |
if people_in_group[i]['age'] >= 21 and people_in_group[i]['drinks'] == True: | |
able_to_drink.append(people_in_group[i]) | |
else: | |
underage.append(people_in_group[i]) | |
if len(able_to_drink) > len(underage): | |
return True | |
else: | |
return False | |
paulo = {'name' : 'Paulo', 'age' : 23, 'drinks' : True } | |
Peter = {'name' : 'Peter', 'age' : 21, 'drinks' : False } | |
James = {'name' : 'James', 'age' : 20, 'drinks' : False } | |
Carlos = {'name' : 'Carlos', 'age' : 18, 'drinks' : False } | |
#create a list of people | |
people_in_group = [paulo, Peter, James, Carlos] | |
#find bar_decision | |
bar_decision = can_we_go_to_bar(people_in_group) | |
#do i have to work tomorrow? | |
noWorkTmrw = False | |
#1 = we go to bar | |
if bar_decision == 1 and not noWorkTmrw: | |
print 'I will go to the bar' | |
#2 = we go to restaurant | |
elif bar_decision == 2: | |
print 'I will go to the restaurant' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment