How do i ignore the space in command line input in python
So i need to append to a file in python. This is a random command line input
file1 This is a sentence.
How do i make it so it "This is a sentence" would be appended to file1 not just "This"
file2 A sentence
How do i make it so it "A sentence" would be appended to file2 not just "A"
This is what i have so far. And any random sentence could be appended to the files
with open(input,'a') as fileA: fileA.write(input)
Pass the second command line arguments as a single argument in the shell:
python /path/to/script.py file1 "This is a sentence."
Alternatively, join the arguments after the filename using str.join:
with open(input, 'a') as fileA: fileA.write(' '.join(input[2:]))
But the alternative solution will not preserve exact count of spaces / tabs.