I am building a small program and thought I would ask CharGPT to build the Framework. I asked it the following question as part of asking a larger question about some code I wanted it to write: |
I got if len(sys.argv) != 3: print("Error: Incorrect number of arguments.") print("Usage: python script.py <IP Address> <Port>") sys.exit(1) ip_address = sys.argv[1] port = sys.argv[2] # Check if the IP Address and Port are properly formatted try: # Check if IP Address is valid parts = ip_address.split('.') if len(parts) != 4 or not all(0 <= int(part) < 256 for part in parts): raise ValueError("Invalid IP Address format") # Check if Port is a valid integer if not (0 < int(port) < 65536): raise ValueError("Invalid Port number”) - Stewart |