python - What's the best way to return multiple values from a function? - Stack Overflow

PHOTO EMBED

Wed Mar 17 2021 07:01:36 GMT+0000 (Coordinated Universal Time)

Saved by @diptish #python

def f(in_str):
    out_str = in_str.upper()
    return True, out_str # Creates tuple automatically

succeeded, b = f("a") # Automatic tuple unpacking
content_copyCOPY

https://stackoverflow.com/questions/38508/whats-the-best-way-to-return-multiple-values-from-a-function