Skip to content

Instantly share code, notes, and snippets.

@liuderchi liuderchi/wk4-q1.py
Last active Dec 9, 2015

Embed
What would you like to do?
wk4-q1.py
mc_menu = [ ["Big Mac" , "beef, cucumber, cheese" , 109 ],
["Filet-O-Fish" , "fish, cheese, mayonnaise" , 99 ],
["McChicken" , "chicken, lettuce, mayonnaise" , 89 ] ]
def print_burger( menu ):
i = 0
while i < len( menu ) :
print ( menu[ i ][ 0 ] ) # print burger
print ( menu[ i ][ 2 ] ) # print price
i = i + 1
def cheese_burger_list( menu ):
answer = []
i = 0
while i < len(menu):
if menu[ i ][ 1 ].find( "cheese" ) != -1 :
answer.append( menu[ i ][ 0 ] )
#alter: answer = answer + [ menu[i][0] ]
i = i + 1
return answer
print_burger( mc_menu )
print cheese_burger_list( mc_menu )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.