What is correct python syntax for this kind of list comprehension? -


Functions: {x * y such as SS & amp; Y is counting intersection, where S is something like this:

  j = 0 [i * j for j ++ and i in s]  

[s1 * 1, s2 * 2, s3 * 3 ...]


For your edited question, you want

  [i * j for j, i enumerate (s)]  

There is no ++ in dragon because it has a clear distinction between statements and expressions.

[i * j for i, calculation in j (xrange (60), start = 40]]

and then another method

  [J * for I * j * (xrange (40, 100), xchange (60))]  

I think that is the best way to do this first because this function calls Reduces and is most readable.

In addition, if you do not know that you absolutely need a list, then use the generator expression

  (for i + 40) * i (60)) in  

This will allow you to process the results at one time and will never store the entire list in memory. You can sum , Generator expressions can be found for accessories such as max , min and most other bilts.


Comments