Exercise 22
Write a program in Python, which returns the first word of a given text. Example for the text: t = 'Python is a wonderful programming language', the program must return PythonSolution
# define a string s
s = "Learning Python in my-course.net"
# initialize the first word at empty string
first=""
# initialize a counter
i = 0
# search the first space in string
while (s[i] != " "):
first = first + s[i]
i = i + 1
print("The first word in the string s is : ", s[:i])
Younes Derfoufi