[Solved] Trying to use a returned value without the other parts of a function [closed]


What you are asking for cannot be done this way. One way to handle this is to refactor the code, to break out the parts that are used in different parts in separate functions and then just call the parts needed, where needed. In this toy example this could be achieved as:

def get_number():
    number = 45
    return number

def print_number(number):
    print(number)

number1 = get_number()
print_number(number1)

number2 = get_number()
print("my number is: {}\n".format(number2))

This gives your better separation between your logic and your ui.

0

solved Trying to use a returned value without the other parts of a function [closed]