(Dec-23-2022, 06:59 AM)vman44 Wrote: Do I have to keep using the %s format, or is there an easier way?
%s
is the old way to do string formatting,should not use it anymore.The way now is to use f-Strings
Post a working code example now have guess,usually so is
userinputs
a string that have to be split it up.If want to add comma can be done lke this.
userinputs = 'hello world 123' userinputs = userinputs.split() with open('file1.txt', 'a') as writer: writer.write(f"{','.join(userinputs)}\n")If i run two times.
Output:hello,world,123
hello,world,123