About 3,980,000 results
Open links in new tab
  1. How to print elements of particular index in list in python?

    Apr 2, 2020 · index() is an inbuilt function in Python, which searches for given element from start of the list and returns the lowest index where the element appears. In your case z=6 and z-1=5, as 5 is not present in the list it returns

  2. python - Printing specific items out of a list - Stack Overflow

    If you want to iterate over a certain list of indexes, you can just specify it like that: print(li[i]) Note that indexes start at zero, so if you want to get the 3 and 4 you will need to access list indexes 2 and 3. You can also slice the list and iterate over the lists instead.

  3. Python List index() – Find Index of Item | GeeksforGeeks

    Jan 7, 2025 · In this article, we are going to explore how to find the index of an element in a list and explore different scenarios while using the list index() method. Let’s take an example to find the index of an Item using the list index method.

  4. Picking out items from a python list which have specific indexes

    For a lazy iterator, you can just use map(L.__getitem__, idx). Note in Python 2.7, map returns a list, so there is no need to pass to list. If you're good with numpy: I have noticed that there are two optional ways to do this job, either by loop or by turning to np.array.

  5. How to Print specific items in a List in Python | bobbyhadz

    Apr 9, 2024 · # Print specific items in a List in Python. Use list slicing to print specific items in a list, e.g. print(my_list[1:3]). The print() function will print the slice of the list starting at the specified index and going up to, but not including the stop index.

  6. Extract Elements from a Python List - GeeksforGeeks

    Dec 3, 2024 · When working with lists in Python, we often need to extract specific elements. The easiest way to extract an element from a list is by using its index. Python uses zero-based indexing, meaning the first element is at index 0. Other methods that we can use to extract elements from list are:

  7. Python | Get elements till particular element in list

    Apr 6, 2023 · Here’s the step-by-step algorithm for getting elements till a particular element in a list using index() and list slicing with enumeration: Initialize the original list test_list. Declare the particular element N till which the elements are required.

  8. Printing Specific Elements of a List in Python - CodeRivers

    6 days ago · To print a single element of a list, you simply use the list name followed by the index of the element in square brackets. In this example, we are printing the element at index 2 of the my_list. The output will be 30. Slicing allows you to extract a sublist from a larger list.

  9. Python List index() - Programiz

    Write a function to find the index of a given element in a list. For example, with inputs [1, 2, 3, 4, 5] and 3, the output should be 2. Did you find this article helpful? In this tutorial, we will learn about the Python List index () method with the help of examples.

  10. Get the index of an item in Python List – 3 Easy Methods

    Jul 21, 2020 · Python’s inbuilt index () method can be used to get the index value of a particular element of the List. Syntax: The start and end parameters are optional and represent the range of positions within which search is to be performed.

  11. Some results have been removed
Refresh