About 546,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. How do I return dictionary keys as a list in Python?

    With Python 2.7, I can get dictionary keys, values, or items as a list:

  3. python - How to convert list to string - Stack Overflow

    Apr 11, 2011 · str(anything) will convert any python object into its string representation. Similar to the output you get if you do print (anything), but as a string.

  4. python - How would you make a comma-separated string from a …

    What would be your preferred way to concatenate strings from a sequence such that between every two consecutive pairs a comma is added. That is, how do you map, for instance, ['a', 'b', …

  5. Get unique values from a list in python - Stack Overflow

    Oct 15, 2012 · 1538 First declare your list properly, separated by commas. You can get the unique values by converting the list to a set.

  6. python - How do I make a flat list out of a list of lists? - Stack …

    If your list of lists comes from a nested list comprehension, the problem can be solved more simply/directly by fixing the comprehension; please see How can I get a flat result from a list …

  7. How to convert comma-delimited string to list in Python?

    Oct 21, 2011 · How to convert comma-delimited string to list in Python? Asked 14 years, 2 months ago Modified 5 years, 7 months ago Viewed 533k times

  8. How to construct a set out of list items in python?

    285 I have a list of filenames in python and I would want to construct a set out of all the filenames.

  9. python - How do I clone a list so that it doesn't change …

    You can use the built-in list.copy () method (available since Python 3.3): new_list = old_list.copy () You can slice it: new_list = old_list [:] Alex Martelli 's opinion (at least back in 2007) about this …

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

    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]