"To spend a penny" is a polite euphemism for going to the toilet, originating from Victorian public toilets where a penny was required to operate the lock.
The phrase was historically used more by women as only women's public toilets required a penny to lock.
Other euphemisms for urination include "take a slash" and "have a waz".
Finally, here is the third part of this series about English slang words and expressions that most British people know, but which will probably confuse almost everyone else! I started this series in 2019. It's only taken me nearly 4 years to get round to finishing it. Learn loads of slang and culture, plus a bit of British history too.