Day 8 of Problem Solving Series In Python

Day 8 of Problem Solving Series In Python | Geethu Talks

Day 8 of Problem Solving Series

Day 8 of Problem Solving Series

👋 Hi friends! Geethu Talks ki welcome. Mee Instagram username valid ena? Ee roju strings and len() tho check cheddam.

🎬 Reel chudaledha? Instagram / YouTube lo @GeethuTalks ni follow avvandi.

🧩 Real-life Problem

Oka app lo username 5 nunchi 15 characters madhya undali. Users enter chesina username valid na kada Python tho check cheyyali.

📋 Task: Username teesukuni length 5 to 15 madhya unte ‘Valid username’, lekapothe error message print cheyyandi.
📥 Sample input: geethu_talks
📤 Sample output: Valid username

📚 Concepts Covered

  • 🔤 Strings
  • 📏 len() function
  • ⛓️ Chained comparison 5 <= x <= 15
  • 🔀 if-else

🧠 Step 1: Logic Build Cheddam

Username oka string. Length telusukovadaniki len():

  1. Username teesukovali
  2. len(username) tho characters count cheyyali
  3. 5 nunchi 15 varaku unte Valid
  4. Lekapothe error message
len(“geethu_talks”) = 12 → 5 ≤ 12 ≤ 15 → Valid

💡 Analogy: len() ante string lo ento characters unnayo count cheyadam: letters, numbers, underscores anni lekkaloki vasthayi.

💻 Step 2: Python Code

username = input("Enter username: ")

if 5 <= len(username) <= 15:
    print("Valid username")
else:
    print("Username must be 5 to 15 characters")

✅ Output
Enter username: geethu_talks
Valid username

🔍 Line by line


CodeMeaning
input(...)Username ni text ga teesukovadam (int() avasaram ledu)
len(username)Characters count
5 <= len(username) <= 15Range check, rendu ends kuda include
print("Valid username")Valid ayithe message
elseInvalid ayithe reason chupinchadam

⚠️ Common Mistake Alert

❌ Wrong: >= badulu > vadithe, exactly 5 characters unna username Invalid avuthundi

username = "geeth"   # 5 characters
if len(username) > 5:
    print("Valid username")
else:
    print("Invalid username")

Result:
Invalid username

✅ Right: Boundary values (5 and 15) include ayye laga <= vadandi.

💡 Bonus tip: len() strings, lists tho work avuthundi, kani numbers tho kaadu. len(12345) rasthe error vasthundi.

📝 Quick Recap

  • ✔️ len() tho string length
  • ✔️ Chained comparison tho range check
  • ✔️ Boundary values test cheyyandi: 4, 5, 15, 16

🏋️ Practice Problems

🟢 Easy: Oka word teesukuni first and last character print cheyyandi (hint: word[0], word[-1]).
Input: python → Output: p n


🟡 Medium: Oka sentence lo spaces entha unnayo count cheyyandi.
Input: I love Python → Output: 2


🔴 Challenge: Password length: below 6 → Weak, 6 to 9 → Medium, 10 or more → Strong.
Input: python@123 → Output: Strong


💬 Mee answers comments lo share cheyyandi!

🚀 Next: Day 9 – Hashtag Generator

Follow @GeethuTalks and stay tuned! 💛

⬅️ Previous: Day 7 of Problem Solving Series In Python

check out our website for more resources

1 thought on “Day 8 of Problem Solving Series In Python”

Leave a Comment