A function for swapping values to return a new word

Here is an example of a function that takes two words as input, swaps their values, and returns a new word:

def swap_values(word1, word2):
    return word2 + " " + word1

This function uses the + operator to concatenate the two input words in reverse order, with a space character in between.

For example, if you call the function with the words "hello" and "world", it would return the string "world hello".

Here's an example usage:

print(swap_values("hello", "world"))  # Output: "world hello"

Note that this function does not modify the original words, but rather returns a new string with the values swapped.

If you want to modify the original words, you can use the swapcase() method, like this:

def swap_values(word1, word2):
    word1 = word1.swapcase()
    word2 = word2.swapcase()
    return word1 + " " + word2

This function uses the swapcase() method to swap the case of each word, and then concatenates the two words with a space character in between.

For example, if you call the function with the words "Hello" and "WORLD", it would return the string "wORLD Hello".