I'm trying to get my code to go through and pop-out after some math has been done. The file being summed is just lists of numbers on separate lines. Could you give me some pointers to make this work because I am stumped.
EDIT: I'm trying to get the transition from the main function to Checker function working correctly. I also need some help with slicing. The numbers being imported from the file are like this:
136895201785
155616717815
164615189165
100175288051
254871145153
So in my Checker
funtion I want to add the odd numbers from left to right together. For example, for the first number, I would want to add 1
, 6
, 9
, 2
, 1
, and 8
.
Full Code:
def checker(line):
flag == False
odds = line[1 + 3+ 5+ 9+ 11]
part2 = odds * 3
evens = part2 + line[2 + 4 +6 +8 +10 +12]
part3 = evens * mod10
last = part3 - 10
if last == line[-1]:
return flag == True
def main():
iven = input("what is the file name ")
with open(iven) as f:
for line in f:
line = line.strip()
if len(line) > 60:
print("line is too long")
elif len(line) < 10:
print("line is too short")
elif not line.isdigit():
print("contains a non-digit")
elif check(line) == False:
print(line, "error")