About 10,900,000 results
Open links in new tab
  1. python - How do I create a list with numbers between two values ...

    Aug 16, 2013 · If you're open to numpy, there are a few functions in it that can generate numbers between 11 and 16: numbers between 11 and 16 with step=0.5: np.arange(11, 16.1, 0.5)

  2. 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 ...

  3. How do I declare an array in Python? - Stack Overflow

    Aug 23, 2022 · There's no way to say in Python "this variable should never refer to anything other than a list", since Python is dynamically typed. * The default built-in Python type is called a list, not an array. …

  4. python - How do I convert user input into a list? - Stack Overflow

    I'm wondering how to take user input and make a list of every character in it. magicInput = input ('Type here: ') And say you entered "python rocks" I want a to make it a list something like this

  5. How do I create a list of random numbers without duplicates?

    Mar 18, 2012 · 12 You can first create a list of numbers from a to b, where a and b are respectively the smallest and greatest numbers in your list, then shuffle it with Fisher-Yates algorithm or using the …

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

    54 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 values:

  7. How do I concatenate two lists in Python? - Stack Overflow

    3238 This question's answers are a community effort. Edit existing answers to improve this post. It is not currently accepting new answers or interactions. How do I concatenate two lists in Python? Example:

  8. Python append () vs. += operator on lists, why do these give different ...

    The overloaded + operator is defined on lists to create a new list whose contents are the elements in the first list and the elements in the second list. So these are really just different expressions used to do …

  9. python - How do I reverse a list or loop over it backwards? - Stack ...

    How do I iterate over a list in reverse in Python? See also: How can I get a reversed copy of a list (avoid a separate statement when chaining a method after .reverse)?

  10. 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 since you …