Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save ofelix03/0259c5b39facd21f85ea599e853fcad6 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 = 0
for fruit in fruits:
total_fruits = total_fruits + fruit[1]
print("total_fruits: ", total_fruits)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment