# File: swap.py # Demonstrate simultaneous assignment # # Matt Bishop, ECS 10, Fall 2012 # # # swapping numbers # a = input("Type input; this will be athe contents of a: ") b = input("Type more input; this will be athe contents of a: ") 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)