I have written a code but it doesn't work as I would have liked : I have a file containing 5 columnes and a few 7 rows as follows
0,5,7,9,0
5,9,7,0,0
9,9,7,0,0
7,7,9,9,0
0,0,0,0,0
5,5,7,0,0
5,0,0,0,0
i want a validation check in python that should allow me to check that there is either a 5,7,9 but none of them is repeated i.e there must be only one occurrence of these numbers,5 and 7 are a must a 9 is optional, the remaining three can be 0. I have written this code but it doesn't work as I wan't . I also want to store the valid rows in a separate list.
My attempt of the program in python is as follows
def validation ():
    numlist = open("scores.txt","r")
    invalidnum=0
    for line in numlist:
        x = line.count("0")
        inv1 = line.count("1")
        inv2 = line.count("2")
        inv3 = line.count("3")
        if x > 2 or inv1 > 1 or inv2 > 1 or inv3 > 1 or line not in ("0","5","7","9"):
        invalidnum=invalidnum+1
           print(invalidnum,"Invalid numbers found" 
        else:
            print("All numbers are valid in the list")

I will appreciate if someone can help me on this.
Thanks