About 387,000 results
Open links in new tab
  1. Best and/or fastest way to create lists in python

    In python, as far as I know, there are at least 3 to 4 ways to create and initialize lists of a given size: Simple loop with append: my_list = [] for i in range(50): my_list.append(0) Simple ...

  2. python - How do I create a list with numbers between two values ...

    Aug 16, 2013 · How do I create a list of numbers between two values? For example, a list between 11 and 16: [11, 12, 13, 14, 15, 16]

  3. List of zeros in python - Stack Overflow

    Dec 16, 2011 · You'd expect that when you create a list of lists that all the lists are different from one another while they're actually references to the same list. This doesn't matter with integers …

  4. python - Make a dictionary (dict) from separate lists of keys and ...

    Imagine that you have: keys = ('name', 'age', 'food') values = ('Monty', 42, 'spam') What is the simplest way to produce the following dictionary ? dict = {'name' : 'Monty', 'age' : 42, 'food' : …

  5. python - Create a dictionary with comprehension - Stack Overflow

    Create a dictionary with list comprehension in Python I like the Python list comprehension syntax. Can it be used to create dictionaries too? For example, by iterating over pairs of keys and …

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

    Apr 16, 2024 · 825 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, …

  7. Create an empty list with certain size in Python - Stack Overflow

    How do I create an empty list that can hold 10 elements? After that, I want to assign values in that list. For example: xs = list() for i in range(0, 9): xs[i] = i However, that gives IndexError:

  8. Python 3 turn range to a list - Stack Overflow

    Jul 14, 2012 · I'm trying to make a list with numbers 1-1000 in it. Obviously this would be annoying to write/read, so I'm attempting to make a list with a range in it. In Python 2 it seems that: …

  9. python - Pandas DataFrame column to list - Stack Overflow

    May 20, 2014 · 226 This question already has answers here: How do I convert a Pandas series or index to a NumPy array? [duplicate] (8 answers) Get list from pandas dataframe column or …

  10. Creating a list of integers in Python - Stack Overflow

    Aug 19, 2021 · Is it possible to create a list of integers with a single line of code, without using any third-party libraries? I tried with the syntax: lst = list(int(1234)) or the syntax: lst = list(int(1,2,3,...