Python Code Challenge: Longest Word Finder

Day 18 of my #100DaysOfCode challenge 🚀 Today I worked on a Python program to find the longest word in a given sentence. The goal was to practice string manipulation and comparison logic. What the program does: • Takes a sentence as input • Splits the sentence into individual words • Compares the length of each word • Stores the longest word found • Prints the final result How the logic works: A sentence is defined as a string The sentence is split into a list of words using .split() A variable longest_word is initialized as an empty string The program loops through each word in the list If the length of the current word is greater than or equal to the stored word, it updates longest_word After the loop ends, the longest word is printed Example: Input sentence: The quick orange fox jumps over the lazy dog Output: Longest word: orange Key learnings from Day 18: – Using .split() for string processing – Comparing string lengths – Iterating through lists efficiently – Strengthening logical thinking skills #100DaysOfCode #Day18 #Python #PythonProgramming #StringManipulation #ProblemSolving #CodingPractice #LogicBuilding #LearnByDoing #ComputerScience #BTech #CSE #AIandML #VITBhopal #TechJourney

  • text

To view or add a comment, sign in

Explore content categories