About 3,250,000 results
Open links in new tab
  1. Using a list index in a variable in python 3.3 - Stack Overflow

    Simply using for i in cust will assign the actual item from your list to i, not the index of the item in the list. Better yet, use for i, customer in enumerate(cust).

  2. How to assign the value of an index of a list to a variable in Python ...

    Jul 17, 2022 · I need to assign the position of any element (i.e., the index integer value) anywhere in the list to a variable so I can control some boundaries. The most important thing for me is to set some conditions for the first character of the string converted to a list.

  3. Python - variable as list index - Stack Overflow

    you can use the function eval ('a [0] [name]'), it will evaluate the string inside as a python code. here is the reference: https://docs.python.org/3/library/functions.html#eval

  4. Unpack Whole List into VariablesPython | GeeksforGeeks

    Feb 5, 2025 · = operator is the most straightforward method to unpack a list into variables. It assigns each element of the list to a corresponding variable in a single line. This method is highly efficient for fixed-length lists where the number of variables …

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

    Apr 27, 2025 · index () method in Python is a helpful tool when you want to find the position of a specific item in a list. It works by searching through the list from the beginning and returning the index (position) of the first occurrence of the element you’re looking for.

  6. Python - Construct variables of list elements - GeeksforGeeks

    Apr 5, 2023 · Use list comprehension to create a list of dictionaries where the key is the element in test_list1 and the value is the corresponding element in test_list2. Use itertools.chain () and reduce () functions to merge all dictionaries into a single dictionary.

  7. How do i store the value and index of a python list in a variable

    Jun 8, 2020 · You could store the whole thing in another list/ numpy array. It would be basically doubling your memory but you could do something like this: result = [] for i, item in enumerate(banks[:5], start=1): result.append([i, item])

  8. Python Lists - Python Guides

    Python lists are one of the most versatile and commonly used data structures in Python programming. They allow you to store multiple items in a single variable, making them essential for organizing and manipulating data efficiently. What is a Python List? A Python list is an ordered, mutable collection of objects. Lists can contain elements of different data types, including numbers, strings ...

  9. How to Access Multiple List Elements by Index in Python

    Instead of accessing them one by one, Python offers several convenient and efficient ways to extract multiple elements using a list of indices. This guide demonstrates the most common methods, including list comprehensions, operator.itemgetter, NumPy array indexing, and standard loops, to access multiple list elements by their indices.

  10. Python List Index() Method - Explained with Practical Examples

    Sep 26, 2024 · Python list index is the method to access the index position of a specified value in the list. Here are some of the common indexing methods you can use in lists, strings and other data structures to access, modify and manage your data in Python efficiently.

  11. Some results have been removed
Refresh