Skip to content

Bp #1130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

Bp #1130

Changes from 1 commit
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
Prev Previous commit
Next Next commit
Ninth challenge completed
  • Loading branch information
BaoPham92 committed Feb 11, 2020
commit de2ce323f310197d2fc6684f7433b83f62002b87
11 changes: 7 additions & 4 deletions src/08_comprehensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@

# Write a list comprehension to produce the array [1, 2, 3, 4, 5]

y = []
# * SOLUTIONS BELOW:
# * OPEN INTERPRETER && RUN: python3 08_comprehensions.py

y = [x for x in range(1,6)]

print (y)

# Write a list comprehension to produce the cubes of the numbers 0-9:
# [0, 1, 8, 27, 64, 125, 216, 343, 512, 729]

y = []
y = [x**3 for x in range(10)]

print(y)

Expand All @@ -26,7 +29,7 @@

a = ["foo", "bar", "baz"]

y = []
y = [x.upper() for x in a]

print(y)

Expand All @@ -36,6 +39,6 @@
x = input("Enter comma-separated numbers: ").split(',')

# What do you need between the square brackets to make it work?
y = []
y = [int(item) for item in x if (int(item) % 2) == 0]

print(y)