Using PyCharm Edu on Windows, need to ask for an IP address (input), use \"ipaddress.ip_address\" to...

70.2K

Verified Solution

Question

Programming

Using PyCharm Edu on Windows, need to ask for an IP address(input), use \"ipaddress.ip_address\" to validate it, only if error(value or type) set the default IP to 192.168.1.1, if no error thenuse the original input. This is the code so far and I need helpplease.

def req_Address():  while True:    try:      address = str(ipaddress.ip_address(input(\"Please enter the ip address you wish scan [192.168.1.1]: \")))    except (ValueError, TypeError):      print(\"Not a valid IP address\")    else:      print(\"Setting the default address to 192.168.1.1\")      address = '192.168.1.1'      print(\"We will use: \" + address)      print()

Answer & Explanation Solved by verified expert
4.1 Ratings (626 Votes)
Codeimport ipaddress importing ipaddress to check the ip addressdef reqAddress fucntion to get the IP address try address inputPlease enter the ip address you wish to scan19216811 user input for    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students