Skip to content

initial commit, first 3 problems done#1

Open
jrl508 wants to merge 11 commits into
masterfrom
jean-lafontant
Open

initial commit, first 3 problems done#1
jrl508 wants to merge 11 commits into
masterfrom
jean-lafontant

Conversation

@jrl508

@jrl508 jrl508 commented Sep 30, 2019

Copy link
Copy Markdown
Owner

No description provided.

Comment thread src/08_comprehensions.py
@@ -12,13 +12,19 @@

y = []

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will range from 0 to 10 not 1-5 try a list comprehension instead
y = [x for x in range(6)]

Comment thread src/08_comprehensions.py

y = []

for x in range(10):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, you can accomplish this easily in 1 line y = [x**3 for x in range(10)]

Comment thread src/08_comprehensions.py

y = []

for i in a:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/08_comprehensions.py

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try this patter for this whole file. This is a "List comprehension" and a really easy way to build and manipulate lists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants