Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Array updating problem for using map(int,input().split()) in python

for taking list input in the array I used

map(int,input().split())

but for using this input method I can’t modify the array if I Iterated like a[I] then it shows

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

TypeError: ‘map’ object is not subscriptable

Can you please tell me how can I resolve this problem?
I am a competitive programmer but I am new to python I must have take input array by using map(int,input().split())

>Solution :

Use list(map(int,input().split())) instead of map(int,input().split()) to convert your input to list, because map function returns an generator which can not be indexed.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading