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 8755059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:46:13+00:00 2026-06-13T13:46:13+00:00

Noob wondering how to improve his code. a, b, c = string.split(enteredDate, /) m31s

  • 0

Noob wondering how to improve his code.

a, b, c = string.split(enteredDate, "/")

m31s = [1, 3, 5, 7, 8, 10, 12]
m30s = [4, 6, 9, 11]

for x in range(len(m31s)):
    x = int(m31s[x])
    if x != int(a) and b != 31:
         print "Invalid date."
for x in range(len(m30s)):
    et cetera...

In case it isn’t clear, I am testing an inputted date to see if it is valid. This is only part of the program. The main question is: what is the best way to test if an element matches ANY element in a list?

My method works… But, I suspect there is a better way to do this. I said boolean in the title because I envision something like:

if secretCode(m31s, int(a)) == True:

Could be a pipedream. Just curious.

Thanks to anyone who takes the time to help.

  • 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-13T13:46:14+00:00Added an answer on June 13, 2026 at 1:46 pm

    You can use the syntax if elem in list. For example:

    >>> if 1 in [1,2,3,4,5]:
    ...     print 'found 1'
    ... 
    found 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a noob at this and was wondering if someone might be able to
I'm a complete noob to Automapper and I'm wondering if its possible to map
Hi I am a noob with linux server stuff. I was wondering if there
I am a noob to PHP just wondering why are we writing the php
Playing around with jQuery a bit (sorry, complete noob) I was wondering why this
I am a NOOB and am designing a relatively basic site. I was wondering
This might be a noob question, but I'm wondering if there's a way to
Complete noob to C , just getting started with some goofing around, wondering how
I'm a bit of a noob at some of this so I was wondering
This is may be a noob question, but I was wondering why do we

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.