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())

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,890 points

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,250 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
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
+2 votes
2 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,400 points
0 votes
1 answer

Need help writing a dataframe into a csv with the help of a loop

Using the following logic you can arrive ...READ MORE

answered Apr 17, 2018 in Python by anonymous
+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 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,206 views
0 votes
0 answers
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,250 points