Python – Create String using Single Quotes

Create a string using single quotes

To create or define a string in Python using single quotes, enclose the string value or literal in single quotes.

'hello world'

We can assign this string value to a variable.

x = 'hello world'

We can use the string literal in an expression, say concatenation of two strings.

x = 'hello world' + 'apple'

Since we defined the string using single quotes, if we would like to use single quote inside this string, we must escape the single quote using backslash character.

'user\'s world'


In the following program, we create a string using single quotes, and print it to console.

Python Program

x = 'hello world'
Run Code Online


hello world


In this tutorial of Python Examples, we learned how to create a new string value using single quotes.