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
If you look at the Python3 document, the list can accept itable.
It is said that it is an object that provides an interpreter with a method called __iter__
.
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.
© 2024 OneMinuteCode. All rights reserved.