#!/usr/bin/env python3 # -*- coding: utf-8 -*- print("XOR two binaries") while True: try: print("Please enter 1st binary (null to exit)") b1 = input() if len(b1) < 1: exit() print("Please enter 2nd binary") b2 = input() x = eval("0b"+b1+" ^ "+"0b"+b2) print(f"{x:#07b}"[2:], "is XOR") except SystemExit: exit() except: print("Only 1 or 0 allowed") if len(b1)==5 and len(b2)==5: #also perform Tunny "addition" # 0&0 = 1 # 0&1 = 0 # 1&0 = 0 # 1&1 = 1 y = "" for i in range(5): if b1[i]==b2[i]: y += "1" else: y += "0" print(y, "is Tunny sum") print("Goodbye")