Trouble with map

0 votes
I want to convert the values of a list using the map function but i am getting a strange result.

s = input("input some numbers: ")
i = map(int, s.split())
print(i)
gives:

input some numbers: 4 58 6
<map object at 0x00000000031AE7B8>
 

why does it not return ['4','58','6']? How do I fix this?
May 2, 2019 in Python by ana1504.k
• 7,910 points
646 views

1 answer to this question.

0 votes
You are using python 3 which returns generators instead of lists.

Call list(x) on the variable after you assign it the map generator.
answered May 2, 2019 by SDeb
• 13,300 points

Related Questions In Python

0 votes
1 answer

How is lambda() used with map() in python?

The map() function in Python takes in ...READ MORE

answered May 20, 2019 in Python by Takeshi
841 views
0 votes
1 answer

Map function with example in python

The map function executes the function_object for each ...READ MORE

answered May 23, 2019 in Python by Imran
868 views
0 votes
1 answer

How to use multiprocessing pool.map with multiple arguments?

The answer to this is version- and ...READ MORE

answered Nov 19, 2020 in Python by Gitika
• 65,770 points
14,569 views
+2 votes
4 answers

How can I replace values with 'none' in a dataframe using pandas

Actually in later versions of pandas this ...READ MORE

answered Aug 13, 2018 in Python by bug_seeker
• 15,510 points
122,492 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,466 views
0 votes
1 answer
0 votes
11 answers
0 votes
1 answer

Increment with ++ in Python

Python doesn't support ++, so we use: number ...READ MORE

answered Nov 8, 2018 in Python by SDeb
• 13,300 points
4,042 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP