7

I am getting above run time error, when I am trying to run an old python codebase into python3. The code looks like below.

index = map(lambda x: x[0], self.history).index(state)

1 Answer 1

16

In Python 3 map doesn't return list but map object - see:

index = map(lambda x: x[0], [(1,2),(3,4)])
print( type(index) )
# <class 'map'>

you have to use list()

index = list(map(lambda x: x[0], self.history)).index(state)
Sign up to request clarification or add additional context in comments.

Comments

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.