I have an array that looks like this:
guest_list = ['P', 'r', 'o', 'f', '.', ' ', 'P', 'l', 'u', 'm', '\n', 'M', 'i', 's', 's', ' ', 'S', 'c', 'a', 'r', 'l', 'e', 't', '\n', 'C', 'o', 'l', '.', ' ', 'M', 'u', 's', 't', 'a', 'r', 'd', '\n', 'A', 'l', ' ', 'S', 'w', 'e', 'i', 'g', 'a', 'r', 't', '\n', 'R', 'o', 'b', 'o', 'c', 'o', 'p']
What I want is an array that looks like this:
guest_list = ['Prof.Plum', 'Miss Scarlet', 'Col. Mustard', 'Al Sweigart', 'Robocop']
In other words, until '\n' appears, I want all of the string values to be combined into 1 value.
Any suggestions?
Edit #1:
Here is part of my original code:
ogl = open('guests.txt') #open guest list
pyperclip.copy(ogl.read()) #open guest list copy
guest_list = list(pyperclip.paste())
listcall on a string or a loop over individual characters.pyperclip.paste().split('\n')split('\n')onogl.read()You could even useogl.read().splitlines()