csc-python-solutions/15/b/2 - Credit Check.py
2021-02-17 12:33:49 +01:00

18 lines
353 B
Python

def check(S):
if len (S.replace(" ", "")) != 16:
return False
for i in range(len(S)):
if i%5==4:
if S[i] != " ":
return False
else:
if not S[i].isdigit():
return False
x = 0
for i in S.replace(" ", ""):
x += int(i)
if not x%10:
return True
return False