Expand|Select|Wrap|Line Numbers
- def verify_isbn_file():
- file_name = pick_a_file()
- input_file = open(file_name)
- for line in input_file:
- initial_multiplier = 10
- check_sum = 0
- raw_number = line.replace('-',' ')
- for character in raw_number[0:-2]:
- if character != ' ':
- int_character = int(character)
- new_value = int_character*initial_multiplier
- check_sum += new_value
- initial_multiplier -= 1
- check_sum = check_sum%11
- check_sum = 11-check_sum
- check_sum = check_sum%11
- check_sum = str(check_sum)
- if check_sum == '10':
- check_sum = 'x'
- if e[-1] != check_sum:
- print line
Expand|Select|Wrap|Line Numbers
- if e[-1] != check_sum:
- print e
What I was wondering was if someone would be so kind as to tell me if there is some way to refer to the last character of each line in the txt file rather then the last character in the entire file?
Example txt file containing valid ISBN and invalid ISBN:
- 0-00-639498-1
0-00-639498-2
0-00-639498-3
0-13-117655-2
0-13-117655-3
0-13-117655-4
Thanks in advance!