min(gameinfo.not_my_planets.values(), key=lambda p: p if p.num_ships < 35)
Trying to get the minimum planet but only while there are planets that have 35 or less ships.
get unexpected token ‘)’ though any ideas?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You missed
elsepart in lambda expression, but you better Rewrite it to:filer(...)will reduce the sequence of planets to those havingnum_ships < 35. Areplanetobjects comparable among them selves or should you compare to an attribute planet,planet.size? If so, you have to add another lambda:If you are not used to functional constructs, just use simple list comprehension (I assumed planets are comparable among them selves):