Skip to content
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

create a dictionary with list comprehension #5

Open
limon opened this issue Aug 6, 2014 · 1 comment
Open

create a dictionary with list comprehension #5

limon opened this issue Aug 6, 2014 · 1 comment

Comments

@limon
Copy link

limon commented Aug 6, 2014

d = {key: value for (key, value) in sequence}

不如直接

d = dict(sequence)

@fengsp
Copy link
Owner

fengsp commented Aug 7, 2014

Yeah, the list comprehension can also be used like d = {key: value * 2 for (key, value) in sequence}, this is why we have list comprehension:)

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

No branches or pull requests

2 participants