Search code examples
pythonpyperclip

How to copy to clipboard that each element in list will contain a new line [pyperclip]


My current input is

input_list = ["5155649076708", "6715439078108", "7123390204635", "6154390460085"]

I would like to copy element to clipboard by using pyperclip which, when copied, will be a following (so when pasting, its easier):

5155649076708
6715439078108
7123390204635
6154390460085

The above is actually the outcome using

for i in input_list:
    print(i)

Is it possible to do something like pyperclip.copy(for)) ? I've tried doing so but no luck.


Solution

  • Maybe try:

    input_list = ["5155649076708", "6715439078108", "7123390204635", "6154390460085"]
    pyperclip.copy("\n".join(input_list))