About 16,300,000 results
Open links in new tab
  1. python - Reference an Element in a List of Tuples - Stack Overflow

    You can get a list of the first element in each tuple using a list comprehension: >>> my_tuples = [(1, 2, 3), ('a', 'b', 'c', 'd', 'e'), (True, False), 'qwerty'] >>> first_elts = [x[0] for x in my_tuples] >>> …

  2. Python - Access Tuple Items - W3Schools

    You can access tuple items by referring to the index number, inside square brackets: Print the second item in the tuple: Note: The first item has index 0. Negative indexing means start from …

  3. python - Accessing a value in a tuple that is in a list - Stack Overflow

    Sep 10, 2018 · x[1] points to the second item in each of the tuples whereas x[0] would point to each of the first items. So this line of code literally reads "return the second item in a tuple for …

  4. Python Tuples - W3Schools

    Tuple is one of 4 built-in data types in Python used to store collections of data, the other 3 are List, Set, and Dictionary, all with different qualities and usage. A tuple is a collection which is …

  5. python - How to reference a tuple as part of an attribute for a ...

    Feb 9, 2019 · In the future, please do add the Python tag yourself. This to help visibility of your question, since most people filter on language, not on secondary types such as dataframes …

  6. Python Access Tuple Item - GeeksforGeeks

    Dec 6, 2024 · Accessing the items in a tuple is easy and in this article, we'll explore how to access tuple elements in python using different methods. Just like lists, tuples are indexed in Python. …

  7. How to Access Tuple Elements in Python? - Python Guides

    Nov 26, 2024 · To access tuple elements in Python, you can use indexing or slicing. For example, if my_tuple = (1, 2, 3, 4, 5), you can access the first element using my_tuple[0], which would …

  8. Python – Accessing nth element from tuples in list

    Feb 3, 2025 · To access the nth element from tuples in a list use indexing to refer to both tuple and element first index accesses tuple and second index accesses the element within tuple. …

  9. Accessing a Value in a Tuple within a List in Python 3

    Jun 27, 2024 · To access a specific value within a tuple, you can use the index of the tuple followed by the index of the value within that tuple. In the first print statement, my_list[1] …

  10. How to Access Elements From a List of Tuples in Python?

    Aug 19, 2022 · To access a specific Tuple element, reference the Tuple with the index value. In this example, the highlighted line retrieves the Offense Description for the matching Offense …

  11. Some results have been removed
Refresh