Last active
December 9, 2015 04:23
-
-
Save liuderchi/a51b105851292b2afab7 to your computer and use it in GitHub Desktop.
wk4-q1.py
This file contains hidden or 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
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