Skip to content

Instantly share code, notes, and snippets.

@liuderchi
Last active December 9, 2015 04:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liuderchi/a51b105851292b2afab7 to your computer and use it in GitHub Desktop.
Save liuderchi/a51b105851292b2afab7 to your computer and use it in GitHub Desktop.
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