Skip to content

Instantly share code, notes, and snippets.

@terryp
Created January 11, 2018 01:10
Show Gist options
  • Save terryp/4c8c50b9091ca097919201ae7435e173 to your computer and use it in GitHub Desktop.
Save terryp/4c8c50b9091ca097919201ae7435e173 to your computer and use it in GitHub Desktop.
Chandler Homework Solution
def hungryCatsPrint(catList):
for cat in catList:
name, demeanor, hours = cat
if demeanor[1] == "1" and hours >= 3:
print(name, demeanor, hours)
def hungryCatsAppend(catList):
results = []
for cat in catList:
name, demeanor, hours = cat
if demeanor[1] == "1" and hours >= 3:
results.append([name, demeanor, hours])
return results
if __name__ == '__main__':
data = [
["Tubby", "0110", 1],
["Snowball", "0010", 3],
["Mr. Fluffles", "1100", 8],
["Garfield", "1101", 1],
["Felix", "0010", 5],
["Sylvester", "1000", 10],
["Stimpy", "0111", 3],
["Skimbleshanks", "0011", 2]
]
print(hungryCatsAppend(data))
hungryCatsPrint(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment