OneBite.Dev - Coding blog in a bite size

declare a string in python

Code snippet on how to declare a string in python

my_string = 'Hello World!'

This sample code is declaring a string, my_string, with a value of “Hello World!“. In Python, strings can be declared using either single quotes (”) or double quotes (""). In this example, single quotes are used. After the equals sign (=), the string is declared between the single quotes, followed by a final closing single quote and a closing parenthesis. This code is saying that the variable my_string will have the value of “Hello World!“.

python