Time complexity answers "how much work?", space complexity answers "how much memory?". It is also a function of the input size n and uses the same O notation.

Input memory vs auxiliary memory

The input itself always takes O(n), so analysis usually counts only the auxiliary memory: the new variables, lists, dicts and the call stack the algorithm creates on top of the input. An algorithm with O(1) auxiliary memory works in place.

Call stack: a loop uses one frame, recursion uses one frame per element
Call stack: a loop uses one frame, recursion uses one frame per element

Reversing a list: copy vs in place

The first function builds a new list: O(n) auxiliary memory. The second moves two indices towards each other and swaps items in place: O(1) auxiliary memory. Both run in O(n) time; only memory differs.