Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def main():
- with open("registrations.txt", 'r', encoding="utf-8") as file:
- try:
- a = open("registrations_good.log", "w")
- v = open('registrations_bad.log', 'w')
- for line in file:
- try:
- operand_1, operation, operand_2 = line.split(' ')
- except ValueError:
- continue
- try:
- match = re.search('\d+', operand_1)
- matchtwo = re.search('\W+', operation)
- if match is None:
- name = True
- else:
- name = False
- raise NameError
- continue
- if matchtwo is not None:
- mail = True
- else:
- mail = False
- raise ValueError
- continue
- if 10 < int(operand_2[:-1]) < 100:
- age = True
- else:
- age = False
- raise ValueError
- if name and mail and age:
- open("registrations_good.log", "a")
- a.write(operand_1, operand_2, operation + "\n")
- else:
- open("registrations_bad.log", "a")
- v.write(operand_1, operand_2, operation)
- except NameError:
- print('nameerror')
- continue
- except ValueError:
- print("Value")
- continue
- except TypeError:
- print("type")
- except ValueError:
- print('Value 2')
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement