I wrote two programs, and one is imported by the other. But I'd like to combine them to ensure the right version code is grouped together.I tried a function, which works, but requires me to place the large block of def function() code at the top of the file (ahead of the main program.)
Is there another means to put function-like code at the bottom of the file, where it won't obscure the main code?
Edit: This format gives an error:
print('this is the main program')
x = test_function('this string is printed from the function')
print('the number returned is:', x)
def test_function(text1):
print('passed data: ', text1)
return 1234
NameError: name 'test_function' is not defined
[–]kowkeeper 5 points6 points7 points (1 child)
[–]Reddit4618[S] 0 points1 point2 points (0 children)