The tram line in downtown Porto, which runs along the Douro River up just before the Luis V bridge area, has only one set of tracks.
So trains have to take turns going each way. One comes up the tracks, and then the other tram switches over to the main tracks and uses them to return down the hill.
Also of note, the things run on the sidewalk.
I’m guessing people are really practiced in being very careful before they walk out their front door on this street.