Oct-12-2020, 02:03 AM
I certainly hope it always prints 'Var: Hello world' since setting Var = 'Hello world' is the last thing you do before printing Var.
This has nothing to do with functions being in different modules. It is just a logic error that you have to fix. This code exhibits the same behavior and the function and function call are in the same module.
This has nothing to do with functions being in different modules. It is just a logic error that you have to fix. This code exhibits the same behavior and the function and function call are in the same module.
def set_string_func(string): print('Received', string) string = 'yellow' ## Why doing this if passed string? print('Returning', string) ## string is always 'yellow' after assignment return string string = set_string_func('mellow')The output is:
Quote:Received mellow
Returning yellow