About 248,000 results
Open links in new tab
  1. How do I get the number of elements in a list (length of a list) in …

    Nov 11, 2009 · Explanation Everything in Python is an object, including lists. All objects have a header of some sort in the C implementation. Lists and other similar builtin objects with a …

  2. python - Type hint for a Sequence or list with known length

    You can't. A list is a mutable, variable length structure. If you need a fixed-length structure, use a tuple instead:

  3. How do I split a list into equally-sized chunks? - Stack Overflow

    How do I split a list of arbitrary length into equal sized chunks? See also: How to iterate over a list in chunks. To chunk strings, see Split string every nth character?.

  4. How to get length of nested list in Python - Stack Overflow

    Jun 29, 2022 · Does this answer your question? How can I get the total number of elements in my arbitrarily nested list of lists?

  5. Create list of single item repeated N times - Stack Overflow

    Apr 16, 2024 · 826 I want to create a series of lists, all of varying lengths. Each list will contain the same element e, repeated n times (where n = length of the list). How do I create the lists, …

  6. Get all (n-choose-k) combinations of length n - Stack Overflow

    For combinations of all possible lengths, see Get all possible (2^N) combinations of a list’s elements, of any length . Note that this is not simply a matter of iterating over the possible …

  7. How to zip two differently sized lists, repeating the shorter list?

    Dec 30, 2017 · import itertools list(zip(my_list, itertools.cycle(another_list))) This will actually give you a list of tuples rather than a list of lists. I hope that's okay.

  8. How Big can a Python List Get? - Stack Overflow

    May 12, 2009 · In Python, how big can a list get? I need a list of about 12000 elements. Will I still be able to run list methods such as sorting, etc?

  9. python - Get lengths of a list in a jinja2 template - Stack Overflow

    How do I get the number of elements in a list in jinja2 template? For example, in Python:

  10. List of zeros in python - Stack Overflow

    Dec 16, 2011 · If you're dealing with really large amount of data and your problem doesn't need variable length of list or multiple data types within the list it is better to use numpy arrays.