TypeError: write() argument must be str, not list

By changing to w.write(str(recorded)) my problem was solved.


You're trying to write to a file using w.write() but it only takes a string as an argument. now_time is a 'datetime' type and not a string. if you don't need to format the date, you can just do this instead:

w.write(str(nowtime))

Same thing with

w.write(recorded)

recorded is a list of events, you need to use it to construct a string before trying to write that string into the file. For example:

recorded = keyboard.record(until='enter')
typedstr = " ".join(keyboard.get_typed_strings(recorded))

Then, inside file_input() function, you can:

w.write(typedstr)