[Solved] bit values from 0 to 255 for valid IP address


If you for some reason can’t use imports, i.e. it is a homework to do it without, following is working version of your code:

b = str(input())
k = b.split('.')

if (len(k)!=4):
  print("input length is incorrect")
else:
  error = False
  for  num  in  k:
      if int(num)<0 or int(num)>255:
        print('Error in your IP addr')
        error = True
        break
  if not error:
    print("Your IP addr is valid")

0

solved bit values from 0 to 255 for valid IP address