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

Chapter 4 vector_sum code not working #30

Closed
julietwk opened this issue Dec 7, 2016 · 2 comments
Closed

Chapter 4 vector_sum code not working #30

julietwk opened this issue Dec 7, 2016 · 2 comments

Comments

@julietwk
Copy link

julietwk commented Dec 7, 2016

Hey, working through some of the examples and it seems the below code is not set up properly even though vector_add has been defined:

def vector_sum2(vectors):
return reduce(vector_add, vectors)

When I try and run the below in the ipython console I get an error saying: "zip argument #1 must support iteration"

vector_sum([1,2,3,4])

Please could you verify that the code is correct/incorrect?

Many thanks!

@joelgrus
Copy link
Owner

joelgrus commented Dec 7, 2016

vector_sum is supposed to take a list of "vectors" (that is, a list of lists) and vector_add them together. you're giving it a vector. it should work if you did

vector_sum([[1, 2, 3, 4]])  # a list with one 4-vector

or

vector_sum([[1], [2], [3], [4]])  # a list of four 1-vectors

@joelgrus joelgrus closed this as completed Dec 7, 2016
@julietwk
Copy link
Author

julietwk commented Dec 8, 2016

Amazing!! Thanks a lot Joel! :)

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