Good morning team. Someone please assist me how I can insert single quotes to a string assigned a variable name. I will appreciate. Thank you.
item = Please insert single quotes here
myString = str(item)
I get the error below:
File “”, line 1
item = Please insert single quotes here
^
SyntaxError: invalid syntax
Sorry, this is in Python language
Please insert single quotes here
it says, but you didn’t?
My aim is to insert single quotes on the sentence. It is I who wrote the string to be contained in the word item. In other words, I want the sentence …please insert single single quotes… to be enclosed in single quotes. It can be any other sentence.
like this:
item = I like my country
myString = str(item)
and the error is:
File “”, line 1
item = I like my country
^
SyntaxError: invalid syntax
what is stopping you then?
I have about 5000 sentences I want to enclose in single quotes. That’s why I am requesting for help. If I jnow how to handle one I will be okay.
that was never within the original question. How is those 5000 sentences stored then? Do you read from file or database?
I wanted to read from a csv file. However, I just choose one statement among the many. Once I know how how to enclose one statement with a single quote I will handle the rest easily.
What do you need the enclosing for then? You don’t want to use the CSV library:
https://docs.python.org/2/library/csv.html#module-contents
what you just told me, should have been in the topic from the beginning.
It has worked well…thank you so much.