Skip to content

Commit 2d8d455

Browse files
committed
update syntax
1 parent 1a5df24 commit 2d8d455

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

Python Tutorial/Dict-comprehension.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ A dictionary comprehension may have an optional associated if clause to filter i
9696

9797
Iterable’s items are skipped for which the if clause is not true.
9898
```tip
99-
Python Dictionary Comprehension If Clause Syntax
100-
{key:value for var in iterable if_clause}
99+
{ key:value for var in iterable if_clause }
101100
```
102101
The following example collects squares of even items (i.e. items having no remainder for division by 2) in a range.
103102
```python
@@ -118,8 +117,7 @@ print(D) # Prints {0: 0, 2: 4, 4: 16}
118117
#### Nested Dictionary Comprehension
119118
The initial value in a dictionary comprehension can be any expression, including another dictionary comprehension.
120119
```tip
121-
Python Nested Dictionary Comprehension Syntax:
122-
{key:{dict comprehension} for var in iterable}
120+
{ key: {dict comprehension} for var in iterable }
123121
```
124122
For example, here’s a simple list comprehension that uses a nested for clause.
125123
```python

0 commit comments

Comments
 (0)