Python String Variables: Quick Guide

You can declare a string variable in Python by using the following method:

str_variable = "Hello, World!"

In this example, we declared a string variable named str_variable and assigned it the value “Hello, World!”. You can also declare string variables using single quotes, as shown below:

str_variable = 'Hello, World!'

In Python, declaring string variables using either double quotes or single quotes is valid.

bannerAds