So, I'm trying to write this code that gets its input from the clipboard and then transforms the input by adding apostrophe and comma to the start and end of each line. This is the code I've written.
import pyperclip
text=pyperclip.paste()
# Separate lines and add stars.
lines = text.split('\n')
for i in range(len(lines)): # loop through all indexes in the "lines" list:
lines[i]="'" + lines[i] + "'," # add apostrophe to each string in "lines" list
text='\n'.join(lines)
pyperclip.copy(text)
However, the problem with this code is that the apostrophe at the end of each line displays on a new line instead of on the same line.
This is the result I get:
But this is what i wanna get:
So, basically I want the apostrophe and comma at the end of each line to appear at the end of each line not on a new line.