We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Swapping Integers

Sneklang makes it easy to swap two values:

cool_person = "Lane"
uncool_person = "TJ"
cool_person, uncool_person = uncool_person, cool_person
print(cool_person)  # TJ
print(uncool_person)  # Lane
# (get rekt lane)

Assignment

Before we do something more tricky, let's start with just swapping some integers. Complete the swap_ints function. It accepts two pointers to integers, and should swap the values of the integers they point to.

You'll need to use a temporary variable to store one of the values while you swap them.