ARGUMENT 2 TO MAP() MUST SUPPORT ITERATION

I"m brand-new to python and also am obtaining an error with the map function that does not make feeling to me. When I call the feature through a list as the second parameter it retransforms the error "TypeError: Argument 2 should assistance iteration" which confoffers me bereason a list should assistance iteration.

You watching: Argument 2 to map() must support iteration

import numpy as npprint(np.array(map(int, raw_input().split().reverse()), float))The code is intended to take in a list, and print out a numpy that is the reverse of the list. Any help as to why the second paramter isn"t iteratable would be appreciated. Thanks!


*

list.reverse() feature reverses the list in-area and retransforms None. If you desire to compose this as one line you may write reversed(raw_input().split()) rather.


*

.reverse() does the reverse in-place and returns None.

See more: Free Online Differential Equations Course S, Top Differential Equation Courses

Get rid of the .reverse() and also call reversed() rather favor so, which have to resolve your issue:

import numpy as npprint(np.array(map(int, reversed(raw_input().split())), float))

*

Thanks for contributing a solution to Stack Overflow!

Please be sure to answer the question. Provide details and also share your research!

But avoid

Asking for aid, clarification, or responding to other answers.Making statements based on opinion; earlier them up via recommendations or personal endure.

To learn more, see our tips on creating good answers.


Message Your Answer Discard

By clicking “Article Your Answer”, you agree to our terms of organization, privacy policy and cookie policy


Not the answer you're looking for? Browse other concerns tagged python numpy or ask your very own question.


Getting the adhering to error as soon as assigning float value to an array: ("'numpy.float64' object does not assistance item assignment", 'developed at index 4')
*

website style / logo design © 2021 Stack Exadjust Inc; user contributions licensed under cc by-sa. rev2021.9.2.40142


Stack Overflow works finest with JavaScript allowed
*

Your privacy

By clicking “Accept all cookies”, you agree Stack Exreadjust can store cookies on your device and also discshed information in accordance via our Cookie Policy.