Untitled
unknown
plain_text
2 years ago
1.1 kB
11
Indexable
from module import LongInt def main(): # instantiate two LongInt objects first = LongInt('0') second = LongInt('0') # initialize input objects try: file = open('LongInts.txt', 'r') lines = file.readlines() file.close() for line in lines: line = line.strip() if line.isdigit(): if first is None: first = LongInt(line) elif second is None: second = LongInt(line) # perform the arithmetic result = first.add_num(second) # display the results first.print_longint() second.print_longint() print("-----------------") result.print_longint() print("\n") else: print(f"Skipping invalid line: {line}") except IOError: print("Error: Unable to read the file.") if __name__ == "__main__": main()
Editor is loading...