Today we will learn about String Function and String Indexing in Python. String Function Python provides built-in functions to modify text: upper() – uppercase lower() – lowercase title() – capitalize each word strip() – remove spaces (both sides) rstrip() – remove right spaces lstrip() – remove left spaces String Indexing String indexing allows us to access characters by position. Starts from 0 Negative indexing starts from -1 Example: text = "Python" print(text[0]) # P print(text[-1]) # n #Python #PythonProgramming #LearnPython #Coding #Programming #Developers #CodeNewbie #TechEducation #ComputerScience #100DaysOfCode #CodingJourney #AI #DataScience
More Relevant Posts
-
🐍 Python Tip: Multi-Line Strings Made Easy Did you know Python lets you write text across multiple lines without using \n again and again? 💡 Just use triple quotes """ """ string = "my name is Danial" long_string = """ my name is danial am 24 years old how old are you """ s line brea print(long_string) ✅ Preserveks automatically ✅ Perfect for paragraphs and messages ✅ Useful for documentation (docstrings) ✅ Cleaner than using multiple \n 🎯 This is one of the many features that makes Python beginner-friendly and powerful at the same time. Clean code + Simple syntax = Python ❤️ #Python #Programming #Coding #LearnPython #Beginners #SoftwareDevelopment #AI
To view or add a comment, sign in
-
Python Sets — Why They’re More Useful Than You Think In simple words: A set in Python is a collection that: • Stores only unique values. • Doesn’t maintain order. • Allows fast membership checks. Why it matters: - Removing duplicates becomes easy. - 'in' operations are much faster than lists. - Set operations like union & intersection are powerful in real-world logic. If you're serious about writing cleaner Python code, sets are essential. Which set operation do you use most in real projects? #Python #LearnPython #DataStructures #BackendDevelopment #PythonDeveloper #Coding
To view or add a comment, sign in
-
-
Sometimes a small detail in Python can change the entire result. Consider this function: def func(a, b=2, c=3): return a + b * c When we call: func(2, c=4) Python assigns the values as follows: a = 2 b = 2 (default value) c = 4 (overridden using a keyword argument) The calculation becomes: 2 + 2 * 4 = 10 This simple example highlights two important Python concepts: • Default Parameters • Keyword Arguments Understanding how Python assigns values to parameters can help you write clearer and more flexible functions. Small concepts like this are what make Python both powerful and elegant. #Python #Programming #Coding #DataScience #AI #SoftwareDevelopment #MachineLearning #Instant
To view or add a comment, sign in
-
💡 Python Tip: Calculating Row Sums in a 2D Matrix In Python, a 2D matrix is typically represented as a list of lists, where each inner list represents a row. Sometimes we need to compute the sum of elements in each row and store the results in a separate list. Example: A = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] row_sums = [sum(row) for row in A] print(row_sums) 📌 Output [6, 15, 24] 🔎 How it works: • The loop iterates through each row of the matrix • sum(row) calculates the total of elements in that row • The result is stored in a new list representing the sum of each row 📊 Time Complexity: O(n × m) Where n = number of rows and m = number of columns This is a simple yet useful pattern when working with data processing, analytics, and matrix operations in Python. #Python #Coding #Programming #PythonTips #DataStructures #Learning
To view or add a comment, sign in
-
🐍 Python f-Strings — The Cleanest Way to Insert Variables into Text ✨ Say goodbye to messy string concatenation 👋 Python gives us f-strings — fast, readable, and beginner-friendly. name = "Danial" text = f"My name is {name}" print(text) ✅ Output: My name is Danial 💡 Why f-strings are awesome: ✔️ Easy to read ✔️ No need for + signs ✔️ No need for .format() ✔️ Works with variables, numbers, and expressions Example with calculation 👇 age = 24 print(f"I am {age} years old") 🚀 If you're learning Python, start using f-strings TODAY — it’s how modern Python code is written. #Python #Coding #Programming #LearnToCode #Developer #100DaysOfCode
To view or add a comment, sign in
-
👉 Question for you: How would you optimize this solution to avoid nested loops? 💡 Python Logic Problem – Find Two Numbers Whose Sum = 9 Today I practiced solving a small array problem in Python. Given a list of numbers: [2, 7, 11, 15, 6, 3] The task was to find two numbers whose sum equals 9. 🔹 Approach I Used: ✔️ Iterated through the list using nested loops ✔️ Compared each pair of numbers ✔️ Checked if their sum equals the target value (9) ✔️ Printed the matching pair 📚 Concepts Practiced: List indexing Nested loops Conditional logic Basic problem-solving approach Problems like this are common in coding interviews and data structure practice, so solving them helps strengthen logical thinking. Small improvements every day → Better programming skills 🚀 Let’s connect if you're also learning Python! #Python #PythonProgramming #CodingPractice #DataStructures #CodingInterview #LearnToCode #DeveloperJourney #100DaysOfCode #ProblemSolving
To view or add a comment, sign in
-
-
💡 Python Tip – List Comprehension (Write Cleaner Code) While practicing Python today, I explored List Comprehension, a powerful feature that makes code more readable and efficient. Instead of writing a traditional loop, we can generate lists in a single line. 🔹 Example Traditional way: numbers = [] for x in range(10): numbers.append(x*x) Using List Comprehension: numbers = [x*x for x in range(10)] ✅ Benefits Cleaner code Faster execution More Pythonic approach 📌 Small improvements like this can make Python code simpler and more efficient. #Python #PythonTips #Coding #DataEngineering #LearningInPublic
To view or add a comment, sign in
-
-
🧠 Python Concept: Tuple Unpacking Python allows you to unpack values directly into variables. Example person = ("Asha", 20, "Engineer") name, age, job = person print(name) print(age) print(job) Output Asha 20 Engineer ⚡ Swapping Variables (Python Trick) a = 5 b = 10 a, b = b, a print(a, b) Output 10 5 No temporary variable needed 🎯 🧒 Simple Explanation 🎁 Imagine opening a gift box 🎁 Inside are three items. 🎁 You take them out and place them into three different baskets. 🎁 That’s tuple unpacking. 💡 Why This Matters ✔ Cleaner variable assignments ✔ Useful in loops ✔ Pythonic swapping trick ✔ Common in real projects 🐍 Python often lets you write cleaner and more expressive code 🐍 Tuple unpacking makes assigning multiple values simple and elegant. #Python #PythonTips #PythonTricks #AdvancedPython #CleanCode #LearnPython #Programming #DeveloperLife #DailyCoding #100DaysOfCode #Tuple #UnpackingTuple
To view or add a comment, sign in
-
-
Today I built a Mini Search Engine in Python. What started as a simple word finder evolved into a ranked search engine with: • Multi-file indexing • Multi-word search (AND logic) • Word frequency ranking • Highlighted results • Colored CLI output This project helped me strengthen my understanding of: Dictionaries and nested data structures File handling String processing Search logic and ranking Small consistent upgrades turned a basic script into a polished tool. Next step: turning it into a web-based search engine. #Python #Programming #SoftwareDevelopment #Learning
To view or add a comment, sign in
-
Explore related topics
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development
This is a great overview of string functions in Python. Learning to manipulate strings is essential for any developer.