Inserting single quotes to a sentence quotes

python

#1

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


#2

Sorry, this is in Python language


#3

Please insert single quotes here it says, but you didn’t?


#4

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.


#5

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


#6

what is stopping you then?


#7

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.


#8

that was never within the original question. How is those 5000 sentences stored then? Do you read from file or database?


#9

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.


#10

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.


#11

It has worked well…thank you so much.