Python in 30 Days: A Practical and Theoretical Approach for Beginner.
Day 4: Python Syntax: Basic Concepts — Strings and Lists
Let’s dive into Day 4 of your Python tutorial, focusing on Strings with simple examples.

·
Strings in Python
Strings are one of the most commonly used data types in Python. They allow you to store and manipulate text.
Let’s dive into Day 4 of your Python tutorial.
Strings in Python
Strings are one of the most commonly used data types in Python. They allow you to store and manipulate text.
Key String Operations:
- Concatenation: Combine two or more strings.
- Repetition: Repeat a string multiple times.
- Length: Find the number of characters in a string.
- Slicing: Extract part of a string.
- Escape Characters: Used to handle special characters in strings.
Creating a string
# Creating a string
message = "Hello, World!"
print(message)
# Output: Hello, World!
String Concatenation
first_name = "John"
last_name = "Doe"
full_name = first_name + " " + last_name
print(full_name)
# Output: John Doe
String Repetition-
We can repeat a string using the *
operator.
# String Repetition
greeting = "Hi! " * 3
print(greeting)
# Output: Hi! Hi! Hi!
String Length
Use len()
to find the length of a string.
# String Length
length = len(message)
print(length)
# Output: 13 (The length of "Hello, World!" is 13)
Slicing a String
We can use slicing to extract part of a string ([start:end]
).
Strings are indexed from 0.
# Slicing a String
print(message[0:5])
# Output: Hello
(Extracts characters from index 0 to 4)
Escape Characters
# Escape Characters
quote = "He said, \"Hello!\""
print(quote)
# Output: He said, "Hello!"
Summary
- Strings are indexed from 0.
- Negative indices access the string from the end (
-1
is the last character). - We can use slicing to extract part of a string (
[start:end]
). - We can repeat a string using the
*
operator. - Use
len()
to find the length of a string.
Happy Coding and Stay Tuned 🙂
Kind is always cool !!!
Share knowledge to gain knowledge !!!!
Be kind and treat people with respect !!!
If you find my blog helpful, then please subscribe, claps and follow to support 🙂

Dharamshala – Where Mountains Meet Monks
Introduction Tucked…
Baijnath Temple – The Timeless Shrine of Lord Shiva
Introduction In…
Norbulingka Institute – A Living Museum of Tibetan Art & Craft
Introduction In…
Bir Billing – The Paragliding Capital of India
Introduction Imagine…
Masroor Rock Temples – The Ellora of the Himalayas
Introduction Hidden…
Palampur – Himachal’s Tea Capital Hidden in Pine Forests
Introduction Tucked…