Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is the file with your answer, do not ren Write your code in it, and save it

ID: 675440 • Letter: T

Question

This is the file with your answer, do not ren Write your code in it, and save it before sub def is valid_socket_address (socket address): a=socket-address. split('·') if len(a) 5: return False for y in range(o,len(a)-1) for x in a: if not x.isdigit(): return False t int(x) if ice or ix255: if y=4 if ice or 1 65535 return False return False return True # This tests your code with the exaples given in the # and is provided only for your convenience. tr for socket_address in ["127.12.23.43:5880" "127.A:-12"]: print ts valid_socket_address(socket_address) Pyt Python split, replace

Explanation / Answer

def is_valid_socket(socket_address):
a = socket_address.split(':')
b = a[0].split('.')
if len(a)!= 2:
return False
if len(b)!=4 :
return False
for i in range(4):
if not b[i].isdigit():
return False
j = int(b[i])
if j < 0 or j > 255:
return False
if not a[1].isdigit():
return False
j = int(a[1])
if j < 0 or j > 7685 :
return False
return True
for socket_address in ['17.1.2.78:7256', '127.A:-5']:
print is_valid_socket(socket_address)
  

you are splitting the address only with " . " but address contain " : " also

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote