input: Write a function to port a Java code snippet to Python 3. The function should take a Java code snippet as input and return its equivalent in Python 3. If the input Java code snippet cannot be converted to Python 3, return False.
  assert port_java_to_python(
    '''public class Foo {
      public int foo(int a, int b) {
        return a + b;
      }
    }'''
  ) == 'def foo(a, b):\n return a + b'
  assert port_java_to_python(
    '''public class Bar {
      public double bar(double c, double d) {
        return c * d;
      }
    }'''
  ) == 'def bar(c, d):\n return c * d'
  assert port_java_to_python(
    '''public class Baz {
      public void baz() {
        System.out.println("Hello World");
      }
    }'''
  ) == 'def baz():\n print("Hello World")'
  assert port_java_to_python(
    '''public class Qux {
      public float qux(float e, float f) {
        return e / f;
      }
    }'''
  ) == False
  assert port_java_to_python(
    '''public class Invalid {
      public int invalid(String g) {
        return g.length();
      }
    }'''
  ) == False
output: def port_java_to_python(java_code):
      import re
      match = re.search(r'public\s+(\w+)\s+(\w+)\s*\(([^)]*)\)\s*{([^}]*)}', java_code)
      if not match:
          return False
      return_type, func_name, params, body = match.groups()
      if return_type not in ['int', 'double', 'void']:
          return False
      params = [p.strip().split()[-1] for p in params.split(',')] if params else []
      body = body.strip()
      if return_type == 'void':
          if not body.startswith('System.out.println'):
              return False
          body = body.replace('System.out.println', 'print').replace(';', '')
          return f'def {func_name}():\n {body}'
      else:
          if not body.startswith('return'):
              return False
          return f'def {func_name}({", ".join(params)}):\n return {body.split()[1]}'