Mastering Strings in Python

🚀 Day 12/60 – Strings in Python (Master Text Manipulation 🔥) Almost everything in real-world data is text. Names. Emails. Logs. Messages. If you master strings, you level up fast 👇 🧠 What is a String? A string is text inside quotes. name = "Adeel" message = 'Hello World' 🔍 Access Characters print(name[0]) # A print(name[-1]) # l ✂️ String Slicing text = "Python" print(text[0:3]) # Pyt print(text[:4]) # Pyth print(text[2:]) # thon 🔧 Common String Methods text = "python" print(text.upper()) # PYTHON print(text.lower()) # python print(text.replace("p", "j")) # jython 🔗 String Concatenation first = "Hello" second = "World" print(first + " " + second) ⚡ Real Example email = "user@gmail.com" if "@gmail.com" in email: print("Valid Gmail") ❌ Common Mistake name = "Adeel ❌ Missing closing quote → Error 🔥 Pro Tip (Very Useful) Use f-strings 👇 name = "Adeel" age = 25 print(f"My name is {name} and I am {age}") 🔥 Challenge for today 👉 Take your name 👉 Print it in uppercase 👉 Print first 3 characters Comment “DONE” when finished ✅ Follow Adeel Sajjad to stay consistent for 60 days 🚀 #Python #LearnPython #PythonProgramming #Coding #Programming

  • graphical user interface

To view or add a comment, sign in

Explore content categories