About 17,800,000 results
Open links in new tab
  1. slice - How slicing in Python works - Stack Overflow

    The first way works for a list or a string; the second way only works for a list, because slice assignment isn't allowed for strings. Other than that I think the only difference is speed: it looks …

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

    Apr 11, 2011 · How can I convert a list to a string using Python?

  3. python - if/else in a list comprehension - Stack Overflow

    Since a list comprehension creates a list, it shouldn't be used if creating a list is not the goal; it shouldn't be used simply to write a one-line for-loop; so refrain from writing [print(x) for x in …

  4. How do I make a flat list out of a list of lists? - Stack Overflow

    Dec 3, 2016 · 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 …

  5. What is the syntax to insert one list into another list in python?

    Sep 20, 2010 · What is the syntax to insert one list into another list in python? [duplicate] Asked 14 years, 9 months ago Modified 6 years ago Viewed 349k times

  6. python - Removing duplicates in lists - Stack Overflow

    Nov 1, 2011 · How can I check if a list has any duplicates and return a new list without duplicates?

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

    joined_list = [item for list_ in [list_one, list_two] for item in list_] It has all the advantages of the newest approach of using Additional Unpacking Generalizations - i.e. you can concatenate an …

  8. join list of lists in python - Stack Overflow

    Apr 4, 2009 · Is the a short syntax for joining a list of lists into a single list ( or iterator) in python? For example I have a list as follows and I want to iterate over a,b and c.

  9. python - What does list [x::y] do? - Stack Overflow

    Jan 27, 2012 · It slices x[startAt:endBefore:skip] if you use skip = 2, every other element the list beginning at startAt and ending at endBefore will be selected. [Remember: indices live …

  10. How do I list all files of a directory? - Stack Overflow

    Jul 9, 2010 · How can I list all files of a directory in Python and add them to a list?

Refresh