I am currently writing a program that needs to interpret user input and turn it into useable data. The number of words in data must be 4, 8, 12, or any multiple of 4. This is because of the format the user must follow while entering data- his input is actually just multiple sets of 4 words. As such, before I attempt to use the data, i want to check to make sure the user followed the format given properly, so I must check to see that the 0th, 4th and 8th place are 3 digit month, and that the 1st, 5th and 9th... you get the idea.
The problem is this: i don't want to check the 0th and 4th and 8th entry in the data, i want to check all the way up to 80 without writing the code to check 20 times.
An example input for this program:
JUL ENT 20 K AUG SAL 2 M MAR OTR 200 K
I am new to Python, so any suggestions would help immensely. Here is what i have written so far.
import re
data_input = input("Please input data.\n")
data_set = re.sub("[^\w]", " ", data_input).split()
data_ready_1 = False
def data_ready_function_1():
if not len(data_set) % 4 == 0:
print("That\'s not a valid input. For formatting help, type \'help\'.'")
data_ready_1 = False
else:
data_ready_1 = True
number = len(data_set) // 4
def data_ready_function_2():
if not (data_set[0]) == ("JAN" or "FEB" or "MAR" "APR" or "MAY" or "JUN" or "JUL" or "AUG" or "SEP" or "OCT" or "NOV" or "DEC"))
print("That\'s not a valid input.'")