Let's say I have these values in an excel sheet:
`"Hello!"
"Testing!"
"My name is " + random.choice(random_names) + "."
"Goodbye!'`
I already have the random_names list earlier in my program:
random_names = ["Harry", "Sam", "Albert"]
How can I transfer these values from an excel sheet into a python list? When I try doing it using openpyxl:
(for phrase_cell in phrase_sheet['A']:
random_phrases_list.append(phrase_cell.value)
I get a list that looks like this when printed:
['"Hello!"', '"Testing!"', '"My name is " + random.choice(random_names) + "."', '"Goodbye!"']
This doesn't work, because when I print the 3rd (i=2) value of the list, this is the output:
"My name is " + random.choice(random_names) + "."
If I remove the quotes from my excel sheet, I get a list that looks like this:
['Hello!', 'Testing!', 'My name is + random.choice(random_names) + .', 'Goodbye!']
And when I print the 3rd value of the list, this is the output:
My name is + random.choice(random_names) + .
Any way I can remove the single quotes that surround each value of the list so that my list would look like this:
["Hello!", "Testing!", "My name is " + random.choice(random_names) + ".", "Goodbye!"]
And if I printed the 3rd value of this list it would be this (for example):
My name is Albert.