PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Challenge by Zygarde
# Problem: Longest Word in a Sentence
# Write a function that takes a sentence (string) and returns the longest word.
# If multiple words have the same maximum length, return the first one.
#
# Input:
# - A string containing words separated by spaces (length ≤ 100).
#
# Output:
# - A string representing the longest word.
#
# Example Runs:
#
# Example 1:
# Input: "The quick brown fox"
# Output: "quick"
# (Explanation: 'quick' and 'brown' are the longest, but 'quick' appears first)
#
# Example 2:
# Input: "Python is amazing"
# Output: "amazing"
# (Explanation: 'amazing' is the longest word)
#
# Example 3:
# Input: "I love AI"
# Output: "love"
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run