Hello there and welcome to 'Learning Python with me'! Today I am going to show you how to create a text analyzer. As I am a little bit sick, I won't be doing a voiceover today, but I will explain step-by-step the workflow I used for this project: - Lists & .append(): I created an empty letters list and used the .append() method to save the three specific letters the user wants to search for. - The .count() method: I applied this directly to the text to easily calculate exactly how many times those saved letters appear. - .split() & len(): I used .split() to break the user's text into separate words, and len() to find out the total word count. - The print() function: Finally, I used print() along with f-strings to display the final analysis, formatting the output clearly so the user can easily read their results. Below you will find a video testing it with a simple phrase. Hope you enjoy it! #Python #PythonProject #Datascience #Sideproject #fyp #programming
More Relevant Posts
-
Hello connections 👋 Welcome to Day 2 of my Python problem-solving series! 🧠 Day 2 Challenge: Check if a number is Prime A prime number is a number greater than 1 that has only two factors: 1 and itself. 👉 Example: Input: 7 → Output: Prime Input: 9 → Output: Not Prime My Approach 1: Basic (Factor Counting Method) num = int(input("Enter a number: ")) c = 0 if num <= 1: print("Not prime") else: for i in range(1, num + 1): if num % i == 0: c += 1 if c == 2: print("Prime") else: print("Not prime") 📌 Explanation: Here, we count how many numbers divide num. If the count is exactly 2 → it’s a prime number. ⚡ My Approach 2: Optimized num = int(input("Enter a number: ")) if num <= 1: print("Not prime") else: for i in range(2, int(num**0.5) + 1): if num % i == 0: print("Not prime") break else: print("Prime") 📌 Explanation: Instead of checking all numbers, we only check up to √n, which makes the solution much faster for large inputs. Now it’s your turn 👇 Try solving it using your own approach or suggest improvements! Let’s learn and grow together 🚀 #Python #CodingChallenge #ProblemSolving #30DaysOfCode #Programming
To view or add a comment, sign in
-
Today I continued my Python functions practice and learned the remaining two important types. Type 3 — Without Arguments & With Return Theory: Function does not take parameters Takes input inside the function Returns the result to the caller Output is printed outside the function Use case: When a function acts like a small tool that collects data and gives back a result. def sum_digits(): n = int(input("Enter number: ")) s = 0 while n > 0: s += n % 10 n //= 10 return s print(sum_digits()) Type 4 — With Arguments & With Return Theory: Function takes input as parameters Does not take input inside Returns the result This type is used in interviews, and real projects Use case: Reusable logic that can be called multiple times with different values. def sum_digits(n): s = 0 while n > 0: s += n % 10 n //= 10 return s print(sum_digits(1234)) Key Learning Same problem can be written in different function types depending on the need. Understanding function design is more important than the problem itself. I’m improving my Python fundamentals step by step #Python #Programming #Learning #CodingJourney #Functions
To view or add a comment, sign in
-
🧠 Python Concept: * (Unpacking Operator in Functions & Lists) Write flexible code like a pro 😎 ❌ Traditional Way nums = [1, 2, 3] print(nums[0], nums[1], nums[2]) ❌ Problem 👉 Fixed length 👉 Not flexible ✅ Pythonic Way nums = [1, 2, 3] print(*nums) 👉 Output: 1 2 3 🧒 Simple Explanation Think of * like “unpacking a bag 🎒” ➡️ Takes all items out ➡️ Spreads them ➡️ Uses them individually 💡 Why This Matters ✔ Cleaner code ✔ Works with any length ✔ Very useful in functions ✔ Widely used in real projects ⚡ Bonus Examples 👉 Merge lists: a = [1, 2] b = [3, 4] merged = [*a, *b] print(merged) 👉 Function arguments: def add(x, y, z): return x + y + z nums = [1, 2, 3] print(add(*nums)) 🐍 Don’t handle items one by one 🐍 Unpack them smartly #Python #PythonTips #CleanCode #LearnPython #Programming #DeveloperLife #100DaysOfCode
To view or add a comment, sign in
-
-
🧠 Python Concept: dict comprehension Create dictionaries in one line 😎 ❌ Traditional Way nums = [1, 2, 3, 4] squares = {} for num in nums: squares[num] = num * num print(squares) ❌ Problem 👉 More lines 👉 Repetitive ✅ Pythonic Way nums = [1, 2, 3, 4] squares = {num: num * num for num in nums} print(squares) 🧒 Simple Explanation Think of it like a shortcut formula 🧮 ➡️ Take each item ➡️ Apply logic ➡️ Store as key:value 💡 Why This Matters ✔ Less code ✔ More readable ✔ Faster to write ✔ Very common in real projects ⚡ Bonus Example even_squares = {num: num * num for num in nums if num % 2 == 0} print(even_squares) 🐍 Build dictionaries smarter 🐍 One line can do it all #Python #PythonTips #CleanCode #LearnPython #Programming #DeveloperLife #100DaysOfCode
To view or add a comment, sign in
-
-
🐍 Day 26 of My 30-Day Python Learning Challenge 🚀 Today I enhanced my Log File Analyzer Project by adding a new feature. 📌 New Feature: Top N Words (User Choice) Instead of showing only top 3 words, users can now choose how many top words they want. 📌 Code: top_n = int(input("Enter number of top words: ")) top_words = sorted(word_count.items(), key=lambda x: x[1], reverse=True)[:top_n] print(top_words) --- 📊 What Changed? • Before → Fixed output (Top 3 words) • Now → Dynamic output (User-defined) --- 💡 Why this matters? • Makes the project flexible • Improves user experience • Closer to real-world applications --- 📊 Quick Question What will happen if user enters a very large number? A) Error B) Full list is returned C) Empty output D) Program stops Answer tomorrow 👇 #Python #MiniProject #ProjectEnhancement #LearningInPublic #SoftwareDeveloper
To view or add a comment, sign in
-
🚨 Python Tip: A Cleaner Way to Loop Most beginners write loops like this 👇 arr = [10, 20, 30] for i in range(len(arr)): print(i, arr[i]) ❌ Works… but not the best way ✅ Better & Pythonic way: arr = [10, 20, 30] for index, value in enumerate(arr): print(index, value) 🔍 Why this is better: ✔ Cleaner syntax ✔ More readable ✔ Less chance of errors ✔ Direct access to both index and value 🧠 Key Takeaway: Prefer enumerate() over range(len()) for looping through lists. Small improvement, big difference in code quality. ❓ Do you use enumerate() or still prefer range()? #Python #Programming #CodingTips #PythonTips #Developers #LearnPython
To view or add a comment, sign in
-
-
🧠 Python Concept: any() vs all() (Advanced Use) Write cleaner condition checks 😎 ❌ Traditional Way numbers = [2, 4, 6, 8] all_even = True for num in numbers: if num % 2 != 0: all_even = False break print(all_even) ❌ Problem 👉 Extra variables 👉 More lines 👉 Less readable ✅ Pythonic Way numbers = [2, 4, 6, 8] all_even = all(num % 2 == 0 for num in numbers) print(all_even) 🧒 Simple Explanation Think of: 👉 all() = “Everything must be True” ✅ 👉 any() = “At least one is True” ⚡ 💡 Why This Matters ✔ Cleaner conditions ✔ No flags needed ✔ Very readable logic ✔ Used in validations & filters ⚡ Bonus Examples names = ["Alice", "Bob", "Charlie"] print(any(name.startswith("A") for name in names)) 👉 Output: True nums = [1, 2, 3] print(all(num > 0 for num in nums)) 👉 Output: True 🐍 Think less, write smarter 🐍 Let Python handle logic #Python #PythonTips #CleanCode #LearnPython #Programming #DeveloperLife #100DaysOfCode
To view or add a comment, sign in
-
-
🚨 Python Gotcha: Copying Lists (It’s Trickier Than You Think!) Many students think they are copying a list… but they’re actually creating a reference 😬 🔍 What’s the issue? Most beginners do this: a = [1, 2, 3] b = a ❌ This does NOT create a new list 👉 It creates a reference to the same list in memory 💡 Example: a = [1, 2, 3] b = a b.append(4) print(a) # [1, 2, 3, 4] 😨 unexpected print(b) # [1, 2, 3, 4] 👉 Why this happens: Both a and b point to the SAME memory location. So any change in b also affects a. ✅ Correct Ways: a = [1, 2, 3] b = a.copy() # Method 1 # or b = a[:] # Method 2 b.append(4) print(a) # [1, 2, 3] ✅ unchanged print(b) # [1, 2, 3, 4] 🧠 Key Takeaway: b = a → reference b = a.copy() or a[:] → actual copy ❓ Did this ever happen to you? #Python #Programming #CodingTips #PythonTips #Developers #LearnPython
To view or add a comment, sign in
-
-
🐍 Python Tip 4: Difference between append() and extend() Many learners get confused between these two list methods. append() Adds the entire object as one element: numbers = [1, 2, 3] numbers.append([4, 5]) print(numbers) Output: [1, 2, 3, [4, 5]] extend() Adds each element individually to the list: numbers = [1, 2, 3] numbers.extend([4, 5]) print(numbers) Output: [1, 2, 3, 4, 5] 💡 Key difference: • append() → adds as a single item • extend() → adds multiple items separately Why this matters? Understanding this helps avoid unexpected list structures, especially while working with datasets or loops. Small concept — but very useful in practice! #Python #PythonTips #Programming #LearnPython #DataScience #CodingTips
To view or add a comment, sign in
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