Skip to content

Instantly share code, notes, and snippets.

@ofelix03
Created April 11, 2021 00:45
Show Gist options
  • Select an option

  • Save ofelix03/d4a3c2f53c4b9817ba5951ced0ce41f1 to your computer and use it in GitHub Desktop.

Select an option

Save ofelix03/d4a3c2f53c4b9817ba5951ced0ce41f1 to your computer and use it in GitHub Desktop.
computing-total-using-for-loop-bad
fruits = [('orange', 1), ('mangoes', 2), ('pineapple', 3), ('banana', 4)]
total_fruits = sum([fruit[1] for fruit in fruits])
print("total_fruits: ", total_fruits)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment