Return function

#I would like to get the ‘return’ that the ‘print’ function gives, i.e. vertical as shown below
def test():
letters = [‘a’, ‘b’, ‘c’]
numbers = [0, 1, 2]
for l, n in zip(letters, numbers):
#print(f’Letter: {l}’)
#print(f’Number: {n}’)
return list(zip(letters, numbers))

if name == “main”:

alt = test()
print("Test= ", alt)

#Returned by Print function:
#Letter: a
#Number: 0
#Letter: b
#Number: 1
#Letter: c
#Number: 2

#Returned by Return function:
#Test= [(‘a’, 0), (‘b’, 1), (‘c’, 2)]

This really depends on what you want to do with your output.

You can try printing your output to a file. Example:

with open("output.txt", mode='w') as f:
    print("hello world", file=f)
1 Like

I want it for TKinter.

Thank you for replying, much appreciated.
BRgds