Python, how do I know if it's applicable to a particular function?

Asked 2 years ago, Updated 2 years ago, 66 views

I'm a beginner who's about to start an algorithm in Baekjun Online Jersey. While solving a simple I/O problem, I was looking at a short code that other people had unlocked I got to know that it's a map. For example..

a = map(int, input().split()) If you use a code like this, the variable a becomes an object called map This If you say a = list(a), I think it's changing to a list type.

An object (in this case, a map) has a function such as a list Is there a way to find out if it can be applied or not? I just put it in a function I wonder if I should do it in a way that'since it doesn't matter.

python map list

2022-09-21 16:59

2 Answers

Of course, you should refer to the Python api document. As you can see with Python, the basic library's materiality is quite consistent.

Looking at the document, the result of the map function is python2 is list and python3 is generator.

The reason for the change is to return to the generator because the memory usage is large when the list is large. In addition, the range was changed to xrange and returned to generator.


2022-09-21 16:59

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.