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

  • Home
  • SEARCH
  • 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 5844707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:19:52+00:00 2026-05-22T12:19:52+00:00

Please excuse (or improve the title) but I have a silly little problem that’s

  • 0

Please excuse (or improve the title) but I have a silly little problem that’s making me very unsure.

I have a list that can contain one to two values, never more, never less and only these two options:

options = ['option one', 'option two']

As I say, sometimes there may only be one of those values in the list so it might just be ['option two',]

The scope for this is simple navigation on a website. I accept a querystring entrance and search the list for those options:

current_option = request.GET.get('option', options[0])
if not current_option in options: current_option = options[0]

If no “option” is provided, it defaults to the first available option.

But now I want to know what the other option is. If "option one" is the input, I want "option two". And if there is only "option one" in the options list, for example, I want the return to be False.

I know I can loop through the list but it feels like there should be a better way of just picking the other value.

  • 1 1 Answer
  • 2 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-05-22T12:19:53+00:00Added an answer on May 22, 2026 at 12:19 pm
    options.remove(current_option)
    options.append(False)
    return options[0]
    

    Edit: If you don’t want to modify options, you can also use the somewhat less readable

    return (options + [False])[current_option == options[0]]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please excuse my lack of knowledge on the topic, but I have very little,
Please excuse me if this is a very novice question, but I am little
Please excuse the simplicity and length of this, but I have a little test
I'm still very new to cocoa touch so please excuse any terminology that I
Please excuse my ignorance I am not very familiar with JavaScript and have been
Please excuse me but I didn't know to give a name to the title
Please excuse the fact that it's not a programming question, but it's still related
Please excuse my ignorance, but I have come across this term owner drawn listbox.
Please excuse the vague question title, but usually I don't do such kind of
Please excuse the awkward title I'll try my best to explain my peculiar problem.

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.