Python Tutorial - Strings

Unlock Premium Features: AI explanations (Hinglish), Indian voice & Videos
Sign Up Free

๐Ÿ”ค Strings - Text/Words Handle Karo

๐ŸŒŸ Real Life Mein:

Text har jagah hai:

๐Ÿ’ฌ "WhatsApp messages" - Strings
๐Ÿ‘ค "Naam, address, email" - Strings
๐Ÿ“ "Password, username" - Strings
๐Ÿ“ง "Email templates" - Long strings

Python mein text ko String kehte hain!

๐Ÿ“ String Banane Ke Tarike

Different Ways to Create Strings
# Single quotes
name = 'Rohan'

# Double quotes
city = "Mumbai"

# Triple quotes - Multi-line
address = """
123, MG Road
Mumbai, Maharashtra
India
"""

๐Ÿ”— String Operations

๐Ÿท๏ธ Name Badge Generator
# User details
first_name = "Rahul"
last_name = "Sharma"
company = "Google"

# Concatenation (+)
full_name = first_name + " " + last_name
badge = "Hi, I am " + full_name

print(badge)  # Hi, I am Rahul Sharma

# f-strings (Modern way)
badge_new = f"Hi, I am {full_name} from {company}"
print(badge_new)

โœ‚๏ธ Useful String Methods

MethodKya Karta HaiExample
.upper()CAPITAL letters"hello".upper() โ†’ "HELLO"
.lower()small letters"HELLO".lower() โ†’ "hello"
.title()Title Case"rahul sharma".title() โ†’ "Rahul Sharma"
.replace()Replace karo"Hi".replace("i","ello") โ†’ "Hello"
.split()Todke list banao"a,b,c".split(",") โ†’ ['a','b','c']
.strip()Extra spaces hatao" hi ".strip() โ†’ "hi"
๐Ÿ“ง Email Validator
email = "  RAHUL@Gmail.COM  "

# Clean up
email = email.strip()        # Extra spaces hatao
email = email.lower()        # Lowercase banao

# Check
if "@" in email and ".com" in email:
    print("Valid email!")
else:
    print("Invalid email!")

๐Ÿค– AI Tutor Unlock Karo!

Apni language mein coding seekho - Hindi, Marathi, Gujarati aur 10+ Indian languages mein!

  • Hinglish mein explanations
  • Real-life examples
  • Beginner-friendly
Free Signup Karo

Example

name = "python"
print(name.upper())