I've used the return function in my code before as I am learning python, but I'm not sure what it does. I've looked it up, but I'm not really sure what it actually does. Can anyone help?
Thanks
(For Ex.)
def break_words(stuff):
words = stuff.split(' ')
return words
def sort_words(words):
return sorted(words)
def print_first_word(words):
word = words.pop(0)
print(word)
def print_last_word(words):
word = words.pop(-1)
print(word)
def sort_sentence(sentence):
words = break_words(sentence)
return sort_words(words)
def print_first_and_last(sentence):
words = break_words(sentence)
print_first_word(words)
print_last_word(words)
def print_first_and_last_sorted(sentence):
words = sort_sentence(sentence)
print_first_word(words)
print_last_word(words)