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.
31sis not a valid variable name. variable names can not start with a digit, though they can contain digits.