while there's nothing wrong with the python script in the link above I would suggest taking advantage of gpiozero, not mentioning subprocess is probably the recommended method to integrate shell commands in Python at this point.
Something like this should be working, YMMV:
from subprocess import call
from gpiozero import Button
my_button = Button(26)
print("Shutting system down")
call("sudo poweroff", shell=True)
... the code above uses BCM26, so you'd wire the button to the pins parallel to the RUN pins, like so: