---
title: "What is meant by string in python?Give suitable example."  
description: "What is meant by string in python?Give suitable example."  
author: "Amrita Bhattacharjee"  
published: 2023-03-28  
updated: 2023-04-18  
canonical: https://www.mindstick.com/forum/157619/what-is-meant-by-string-in-python-give-suitable-example  
category: "python"  
tags: ["python"]  
reading_time: 3 minutes  

---

# What is meant by string in python?Give suitable example.

What is meant by [string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp) in [python](https://www.mindstick.com/articles/75378/simple-yet-useful-tips-when-using-python)?Give suitable example.

## Replies

### Reply by Aryan Kumar

In Python, a string is a sequence of characters enclosed within quotes, either single quotes ('...') or double quotes ("..."). Strings are one of the fundamental data types in Python and are used to represent text-based data.

```python
my_string = "Hello, World!"
# output: Hello, World!
```

In the below example to separated strings containing the first name and last name concatenated to create a new string the full name. “+” operator is used to join two strings together with a space between them.

```plaintext
first_name = "Aryan"
last_name = "Kumar"
fullname = firstname+" "+ last_name
print(full_name)
#output: Aryan Kumar
```

There are three ways to introduce strings in python:\
1. Single Quoted

2. Double Quoted\
3. Triple Quoted\
\
Regardless of whether you use single quotes `'` or double quotes `"`, the resulting strings are equal.\
An error will occur if you try to insert a newline directly into a string enclosed by single or double quotes. To insert a newline, you need to use `\n`.\
Within a string enclosed in triple quotes, line breaks can be directly included without any additional escaping.

### Reply by Krishnapriya Rajeev

In Python, a string is a group of characters. It can be created by enclosing a sequence of characters within single quotes ('...'), double quotes ("..."), or triple quotes("…").

Example:

```plaintext
str = '''MindStick''' # Triple quotes
str1 = "MindStick"    # Double quotes
str2 = 'MindStick'    # Single quotes
print(str)
print(str1)
print(str2)			 # str, str1, str2 are equivalent

OUTPUT:
MindStick
```

```plaintext
str3 = '''Mind
Stick'''   			# Mulit-line String, not equivalent to str, str1, str2

OUTPUT:
Mind
Stick
```

Strings are used to represent names, addresses, messages, etc. In python, we do not have a character datatype to represent a single character.

Also, we can access each character in a string using indexing. String indexing starts at 0, so the first character in a string is at index 0, the second character is at index 1, and so on. However, we can also use negative indexing to access characters from the end of the string. In negative indexing, the last character is at index -1, the second-to-last character is at index -2, and so on.

```plaintext
str = "MindStick"
c = str[-1]		#stores last character in the string
print(c)

OUTPUT:
k
```

Strings are used to represent names, addresses, messages, etc. In python, we do not have a character datatype to represent a single character.

Also, we can access each character in a string using indexing. String indexing starts at 0, so the first character in a string is at index 0, the second character is at index 1, and so on. However, we can also use negative indexing to access characters from the end of the string. In negative indexing, the last character is at index -1, the second-to-last character is at index -2, and so on.

```plaintext
str = "MindStick"
c = str[-1]		#stores last character in the string
print(c)

OUTPUT:
k
```


---

Original Source: https://www.mindstick.com/forum/157619/what-is-meant-by-string-in-python-give-suitable-example

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
