DEV Community

Cover image for String value in Python
Keshav Jindal
Keshav Jindal

Posted on • Updated on

String value in Python

Introduction
We extensively use string values in Python, in the form of messages or quotes in the designed code as it makes an easier task for the user to understand the situation. Strings in python are surrounded by either single quotation marks or double quotation marks.
Image description

'hello' it is the same as "hello”. You can execute the value by using print(), for example, print(“hello world”). Assigning a string value to a variable is done with the variable name followed by an equal sign and the string value which you want to assign.
Concatenation
We can also assign multiple values to a variable and add them with the help of Concatenation.
Access to string value
To check if a certain phrase or a character is not present in the value, then we can use the keyword(not in). for example, a=” string value in Python”
print(‘java’ not in a)
Indexing
We can access individual characters using indexing. Index starts from 0. In Python, we can also do negative indexing like -1,-2, etc.
Image description

Top comments (0)