# File: swap.py # Demonstrate simultaneous assignment # # Matt Bishop, MHI 289I, Fall 2022 # # swapping numbers # a = input("Type input; this will be the contents of a: ") b = input("Type more input; this will be the contents of b: ") print("a =", a, "b =", b) # first swap: traditional tmp = a a = b b = tmp print("Traditional swap: a =", a, "b =", b) # now using simultaneous assignment a, b = b, a print("Simultaneous assignment swap (swapping back): a =", a, "b =", b)