mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-11 17:24:29 +02:00
correction for the set comprehension in py3 (#2358)
This commit is contained in:
@@ -602,7 +602,7 @@ list(filter(lambda x: x > 5, [3, 4, 5, 6, 7])) # => [6, 7]
|
|||||||
[x for x in [3, 4, 5, 6, 7] if x > 5] # => [6, 7]
|
[x for x in [3, 4, 5, 6, 7] if x > 5] # => [6, 7]
|
||||||
|
|
||||||
# You can construct set and dict comprehensions as well.
|
# You can construct set and dict comprehensions as well.
|
||||||
{x for x in 'abcddeef' if x in 'abc'} # => {'d', 'e', 'f'}
|
{x for x in 'abcddeef' if x not in 'abc'} # => {'d', 'e', 'f'}
|
||||||
{x: x**2 for x in range(5)} # => {0: 0, 1: 1, 2: 4, 3: 9, 4: 16}
|
{x: x**2 for x in range(5)} # => {0: 0, 1: 1, 2: 4, 3: 9, 4: 16}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user