1

sample input:

32 42 4 423 43 2 3

my code to convert the input into a list of integers:

mylist = map(int, (list(input().split(' '))))
print(mylist)

output of my code:

<map object at 0x7f0eb38f1d30>

Expected output:

[32, 42, 4, 423, 43, 2, 3]

1 Answer 1

1

If you want a list use a list comprehension:

mylist = [int(x) for x in input.split(' ')]

The result of map is a map object, and you're getting it's representation.

You can convert it to a list:

mymap = map(int, (list(input().split(' '))))
print(list(mymap))
Sign up to request clarification or add additional context in comments.

2 Comments

map() has such a useless output, why didn't the python3 writers make it return a list by default? When is <map object at 0x7f0eb38f1d30> ever useful?
When you don't need the list. If you're applying a function to a very long list it's often wasteful to build it in memory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.