Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -544,12 +544,12 @@ Use a tuple-comprehension to extract comma-separated numbers from a string, conv
Replicate the functionality of the the following code by writing a list comprehension.
```python
# skip all non-lowercased letters (including punctuation)
# append 1 if lowercase letter is "o"
# append 1 if lowercase letter is equal to "o"
# append 0 if lowercase letter is not "o"
out = []
for i in "Hello. How Are You?":
if i.islower():
out.append(1 if i is "o" else 0)
out.append(1 if i == "o" else 0)
```

</div>
Expand Down Expand Up @@ -653,7 +653,7 @@ or
<!-- #region -->
**Translating a For-Loop: Solution**
```python
>>> out = [(1 if i is "o" else 0) for i in "Hello. How Are You?" if i.islower()]
>>> out = [(1 if i == "o" else 0) for i in "Hello. How Are You?" if i.islower()]
>>> out
[0, 0, 0, 1, 1, 0, 0, 0, 1, 0]
```
Expand Down