Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7986299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:49:05+00:00 2026-06-04T11:49:05+00:00

min(gameinfo.not_my_planets.values(), key=lambda p: p if p.num_ships < 35) Trying to get the minimum planet

  • 0
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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T11:49:06+00:00Added an answer on June 4, 2026 at 11:49 am

    You missed else part in lambda expression, but you better Rewrite it to:

    min(filter(lambda p: p.num_ships < 35, gameinfo.not_my_planets.values()))
    

    filer(...) will reduce the sequence of planets to those having num_ships < 35. Are planet objects comparable among them selves or should you compare to an attribute planet,
    planet.size? If so, you have to add another lambda:

    min(filter(lambda p: p.num_ships < 35, gameinfo.not_my_planets.values()), key=lambda p:p.size)
    

    If you are not used to functional constructs, just use simple list comprehension (I assumed planets are comparable among them selves):

    min( p for p in gameinfo.not_my_planets.values() if p.num_ships < 35)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

unset(min($arr)) is not working in php min($arr) do gives the minimum and unset($arr[1]) also
I want to use min(5,10) , or Math.max(4,7) . Are there functions to this
Right now I have def min(array,starting,ending) minimum = starting for i in starting+1 ..ending
Query select min Price, min year from tblProduct returns empty () results. I only
SELECT MIN(retail) FROM books WHERE category = 'COMPUTER' works fine, but when I include
Can I put text min/max values for jquery ui slider and when scroll to
What exactly are the min and max prefixes in CSS? And are there any
How to get the min and max heap size settings of a VM from
Which are the min/max values I can pass to an Integer/Number? Does Integer use
Possible Duplicate: jquery-min version? These two files are already included while creating a new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.