Can't speak for London, but Edinburgh has plenty of loos to use, though not that many true public loos.
There are public loos in the Meadows (at least for men) and in Princes St. Gardens. You can also find loos without a charge at any of the museums and also in the courtyard of Holyrood Palace. In addition, stores like Marks & Spencer, Jenners etc. all have loos available to the public.
However, many pubs and stores, particularly in the touristy areas, will not allow you to use the loos without purchasing something because they've gotten frustrated with loos being 'over-run' by tourists who use the facilities, but don't buy anything.
I think London has plenty more public loos, plus again all the museums and probably some in the Tube stations. In general, the situation is far better than in most US cities.
Kate