About 51 results
Open links in new tab
  1. python - What does "list comprehension" and similar mean? How does …

    I've seen a lot of confusion lately (on other SO questions and from coworkers) about how list comprehensions work. A wee bit of math education can help with why the syntax is like this, and …

  2. python - if else in a list comprehension - Stack Overflow

    Feb 2, 2013 · python list list-comprehension if-statement edited Mar 28, 2023 at 3:21 Dan D. 75.1k 15 111 129

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

    List comprehension where an if statement follows a for statement (case (2) above) is similar to the math notation to define a subset from a given set, so [x for x in iterable if m<x<n] is similar to {x ∈ iterable | …

  4. python - How can I use list comprehensions to process a nested list ...

    406 Here is how to convert nested for loop to nested list comprehension for your example:

  5. python - List comprehension with if statement - Stack Overflow

    Mar 18, 2013 · python if-statement list-comprehension edited Nov 29, 2017 at 20:50 Martijn Pieters 1.1m 326 4.2k 3.5k

  6. python - List comprehension list of lists - Stack Overflow

    Feb 2, 2014 · I have a list of lists, and would like to use list comprehension to apply a function to each element in the list of lists, but when I do this, I end up with one long list rather than my list of lis...

  7. List comprehension in Python, how to - Stack Overflow

    Oct 1, 2013 · I am reading about Python and I want to do a problem with list comprehensions. The problem is simple: Write a program that gives the sum of the multiples of 3 and 5 before some n …

  8. Understanding list comprehensions in Python - Stack Overflow

    Jul 16, 2016 · Understanding list comprehensions in Python Asked 9 years, 6 months ago Modified 3 years, 1 month ago Viewed 1k times

  9. python - Understanding the syntax of list comprehensions - Stack …

    Jul 16, 2021 · Python list comprehensions are for loops executed in a list to generate a new list.The reason python list comprehensions are evaluated backward from or right to left is because usually …

  10. Using an 'or' operator in a basic python list comprehension

    Nov 26, 2020 · Question: How can I use OR in a python list comprehension? I am looking to output any number between 0-99 that is either divisible by 5 or 7 with no remainder. I have the following code: …