Answer:
Following are the program in the Python Programming Language.
# define function.
def return_second_word(sentence):
#remove all the spaces from the sentence
sentence=' '.join(sentence.split())
#the list is split from spaces
my_list = sentence.split(" ")
#return the list
return my_list[1]
#define main function
def main():
#get input from the user
se = input("Enter the sentence: ")
#print and call the function
print(return_second_word(se))
#condition to execute the main function
if __name__ == "__main__":
#call main function
main()
<u>Output:</u>
Enter the sentence: I love python
love
Explanation:
Here, we define the function i.e., "return_second_word()" and pass an argument "sentence", inside the function.
- Remove all the spaces from the variable "sentence" and again store in the variable "sentence".
- Set the variable "my_list" that store the split value of the variable "sentence".
- Return the list and close the function.
Finally, we define the main function and inside the main function.
- Get input from the user in the variable "se"
- And pass the variable "se" in the argument list during the calling of the function "return_second_word()".
- Then, print and call the function "return_second_word()".
- Set the if statement to call the main function then, call the main function.