Skip to content

Instantly share code, notes, and snippets.

@mayankdawar
Created August 7, 2020 20:53
Show Gist options
  • Save mayankdawar/ffd2ff6dae08e70f1c2189b7332b5c55 to your computer and use it in GitHub Desktop.
Save mayankdawar/ffd2ff6dae08e70f1c2189b7332b5c55 to your computer and use it in GitHub Desktop.
Iterate through the contents of l_of_l and assign the third element of sublist to a new list called third.
third = []
l_of_l = [['purple', 'mauve', 'blue'], ['red', 'maroon', 'blood orange', 'crimson'], ['sea green', 'cornflower', 'lavender', 'indigo'], ['yellow', 'amarillo', 'mac n cheese', 'golden rod']]
for i in l_of_l:
third.append(i[2])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment