-1

I have the following function:

def eg_fun(eg:int):
    """example function
    """
   
    if eg > 2:
        return 2, 4
    else:
        return 'no', None

In the function definition how I can put different returning Tuple?

If I would have a single return type I writing: def eg_fun(eg:int) -> Tuple[int, int]:

But in this case I have two different return type, the first one is Tuple[int, int] while the second one is Tuple[str, None]

Will
  • 1,619
  • 5
  • 23

1 Answers1

1

If you are running python 3.10 -> Tuple[int, int] | Tuple [str, None] should work

Paul Rudi
  • 26
  • 3