'Replace the order of parametrs of the function

    # STEP 2 - FORMATNAME
    # Format Name -  takes in first and last name and  returns it as Last, First Name

    def format_name(first, last):
        # print("Student: TODO")
        str(last,first)
        return 

def main():
    print(format_name('Bill','Nye'))
    
if __name__ == "__main__":
    main()

TypeError: decoding str is not supported

Please help me to solve this problem. I have to replace the order of parametrs of the function.



Solution 1:[1]

How about this:

def format_name(first, last):
    return last, first

last, first = format_name('John', 'Snow')
print(f"{last.strip()} {first.strip()}")  # Snow John

function returns two objects, which you can parse into two different variables. Then you can apply strip function on them.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1