DEV Community

Cover image for String value in Python
Keshav Jindal
Keshav Jindal

Posted on • Edited on

4 3

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

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay