Writing A Function To A Text File [duplicate]

  python

Writing Output To A Text File

here is some example code

def func_here(hey):
   print(hey)
def main():
   hey = input("Test> ")
   func_here(hey)

then the output should be whatever the output of func_here() is. Now is there a way to take that output and write it to a text file, so instead of it being in a terminal window, it will appear in "example.txt"?

Source: Python Questions

LEAVE A COMMENT