1name = "Rick Sanchez"
2first_name = name.split(' ').pop(0)
3print(first_name)
4#Output
5'Rick'
6
7#BONUS
8#From strings in a list (using list comprehension)
9names = ["Rick Sanchez", "Morty Smith", "Summer Smith", "Jerry Smith", "Beth Smith"]
10first_names = [name.split(' ').pop(0) for name in names]
11print(first_names)
12#Output
13['Rick', 'Morty', 'Summer', 'Jerry', 'Beth']
1def print_first_word():
2 words = "All good things come to those who wait"
3 print(words.split().pop(0))
4 #to print the last word use pop(-1)
5print_first_word()