So I'm trying to make a check digit function, and embarrassingly, I've already run into a snag early on that I've been trying to search the problem for, but most of the explanations I've run into are unfortunately beyond my comprehension. I'm hoping someone could give me a specific run-down as to what my problem is right now
mam = []
def check_digit():
a = int(input("Please enter your 10 digit book number"))
b = str(a)
for c in b:
mam.append(c)
print(c)
check_digit()
Sorry about no set names for variables, I prefer coding this way even if it eventually gets awkward for others to read. Well anyway, every time I write in an integer which starts with 0, the Syntax error "Invalid token" appears and I don't know how to solve it. Could anyone help me? I would be grateful
Fixed. I really need to update Python, I'm running 2.7 at the moment.
raw_input solved the issue
You cast
a
as an int, but never use it as an int. Try looping through the input string directly.Other answers' explanations about the source of the problem make sense to me. This should fix the problem, since you never need to interpret your input as an integer at all.