Validate IP4 address
def validateIP(ip):



I would expect a name starting is (a useful hint that it returns a Boolean rather than some more complex validation data structure) and explicitly mentioning IP v4 (since the current name is misleading). E.g. is_valid_IPv4_address.




  #split them by '.' , and store them in an array
  #check the array if the length is 4 length
  arr = ip.split('.')
  if len(arr) != 4:
    return False



The comments don't tell me anything which the code doesn't already. In general, good comments explain why, not what.




  #0 check for special edge cases when non-digit
  #1. check if they are digit, 
  #2. check if check the integer is between 0 and 255

  for part in arr:
    .. various conditions which return False
  return True



IMO it would be more Pythonic to use all: I would boil the whole function down to

    parts = ip.split('.')
    return len(parts) == 4 and all(is_valid_IPv4_address_part(part) for part in parts)





    if len(part) &gt; 1:
      if part[0] == '0':
        return False



This isn't in the spec. It's a reasonable constraint, but you should check with the person who gave you the spec before writing the code, or at least put in a comment saying that you're making an assumption about the true intentions of the specifier.




    if not part.isdigit():
      return False



This is buggy. (Before testing I thought there was an issue which should be bounced back to the specifier. Upon testing, I found that some of my test cases caused validateIP to throw an exception).

What is the expected output for these test cases?

¹.¹.¹.¹
١.١.١.١
...
①.①.①.①