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

You can add in a function parameter that allows you to print out within the function or not: def GetNumber(print_num=False): number = 45 if print_num: print(number) return number GetNumber(True) num = GetNumber() print(“my num is: {}\n”.format(num)); GetNumber(True) will print out the number from within the function, whereas GetNumber() will simply return the number without printing … Read more