Python: Extract the nth element from a given list of tuples using lambda
Write a Python program to extract the nth element from a given list of tuples using lambda.
Sample Solution:
Python Code :
Sample Output:
Original list: [('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)] Extract nth element ( n = 0 ) from the said list of tuples: ['Greyson Fulton', 'Brady Kent', 'Wyatt Knott', 'Beau Turnbull'] Extract nth element ( n = 2 ) from the said list of tuples: [99, 96, 94, 98]
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Python program to check whether a specified list is sorted or not using lambda.
Next: Write a Python program to sort a list of lists by a given index of the inner list using lambda.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics