On 08/12/2021 09.45, Roland Mueller via Python-list wrote: > Hello > > ti 7. jouluk. 2021 klo 19.47 vani arul (arulvan...@gmail.com) kirjoitti: > >> Hey There, >> Can someone help to understand how a python function can return value with >> using return in the code? >> It is not not about explicit or implicit function call. >> >> > Not sure whether I understood your question: I have a simple example about > return. > * f() and h() explicitely return something > * g() and h() return None > > BTW, also Python documentation tool pydoc has an article about return. > > #!/usr/bin/python > > def f(): > return 42 > def g(): > pass > def h(): > return > > if __name__ == "__main__": > print(f"f(): {f()}") > print(f"g(): {g()}") > print(f"h(): {h()}") > > Result: > f(): 42 > g(): None > h(): None > > Pydoc: > $ pydoc return > > BR, > Roland > > >> Thanks >> Vani
plus Python, unlike some other languages, allows us to return multiple values, either as a collection or as an implied-tuple: def function_list(): a_list = [ i for i in range( 9 ) ] return a_list def function_multiples(): a = 1 b = 2 c = 3 return a, b, c thus: x, y, z = function_multiples() -- Regards, =dn -- https://mail.python.org/mailman/listinfo/python-list