Map function in Python version 3


#1

Hi,

What will be the equivalent of the following command in Python 3.
orderItemsMap = map(lambda rec: float(rec.split(",")[4], orderItemsFilter)

As per the Python 3 tutorial i also tried typecasting the entire thing in LIST as below, but that also did not work.
orderItemsMap = list(map(lambda rec: float(rec.split(",")[4], orderItemsFilter))

Do note that when i try using the map function using a single List it works fine, but when I tried using the file structure in our course, it did not work.
Kindly advise.


#2

can you check the type of the orderItemsFilter? If it is giving as a type filter then convert it to list using below command

orderItemsFilter = list(filter(lambda rec: int(rec.split(",")[1]) == 68880, orderItems))

then use below code to the print the map function

orderItemsMap = list(map(lambda rec: float(rec.split(",")[4]), orderItemsFilter))
for i in orderItemsMap: print(i)

#3

Works perfect. Thanks


#4