Showing posts with label Functions - swap two numbers. Show all posts
Showing posts with label Functions - swap two numbers. Show all posts

Functions - swap two numbers

# Functions - swap two numbers

def fn_swap(x, y):
    x, y = y, x
    return x, y

# Main program

num1 = int(input("Enter numbre :"))
num2 = int(input("Enter numbre :"))

print("Numbers before swap :", num1, num2)
num1, num2 = fn_swap(num1, num2)
print("Numbers after swap :", num1, num2)