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 in Python by ana1504.k
• 7,350 points
10 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 by SDeb
• 12,120 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 in Python by Takeshi
9 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 in Python by Imran
17 views
+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,310 points
3,794 views
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
777 views
+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 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 122 views
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
• 12,120 points
35 views