code_check.py

 avatar
unknown
plain_text
3 years ago
1.6 kB
4
Indexable
#import code_check file functions
from code_check import funcbasic
from code_check import funcPositional
from code_check import funcUPC
#state lists
basicList = []
positionalList = []
upclist = []
none = []

response = str(input("Please enter code (digits only) (enter 0 to quit) "))

#make a loop until input is equal to 0
while response != "0":
    if funcbasic(response):
        print("-- code:", response, "valid Basic Code.")
        basicList.append(response)

    if funcPositional(response):
        print("-- code:", response, "valid Position Code.")
        positionalList.append(response)

    if funcUPC(response):
        print("-- code:", response, "valid UPC Code.")
        upclist.append(response)

    if funcbasic(response) != True and funcUPC(response) != True and funcPositional(response) != True:
        print("-- code:", response, "not Basic, Position or UPC code.")
        none.append(response)

    response = str(input("Please enter code (digits only) (enter 0 to quit) "))
#join the lists to remove square brackets
b = (','.join(basicList))
p = (','.join(positionalList))
u = (','.join(upclist))
n =(','.join(none))
c = "None"
#print summary
print()
print('Summary')
#create if statements for if list is empty
if len(basicList)!=0:
    print("Basic: {}" .format(b))
else:
    print("Basic: {}" .format(c))
if len(positionalList) != 0:
    print("Position: {}".format(p))
else:
    print("Position: {}" .format(c))
if len(upclist)!=0:
    print("UPC: {}".format(u))
else:
    print("UPC: {}".format(c))
if len(none)!= 0:
    print("None: {}".format(n))
else:
    print("None: {}".format(c))




Editor is loading...