MWZ

MINDWAREZONE

String Basics

A string is a sequence of characters enclosed in single quotes (' '), double quotes (" "), or triple quotes (''' ''' / """ """).

Key Points

  • Strings store text data.
  • Strings are immutable (cannot be changed after creation).
  • Indexing starts from 0.

Example 1:

name = "Alice"
print(name)
            

Output

Alice
            

Example 2:

message = 'Hello World'
print(message)
            

Output

Hello World
            

Example 3:

text = """This is
a multi-line
string."""
            

Output

This is
a multi-line
string.