Public transportation is one of the best ways to get around in a new city, especially if the city has an excellent transit system (such as the Paris Metro or London Underground).
There are a few cities where public transit is just not worth it unless you are willing to spend half of your trip waiting around for busses and trains - *unless* you are staying near a bus or train stop and everything you want to see is near a bus or train stop. Edmonton, Canada has a terrible transit system (although they are trying to make it better), and so does Los Angeles. I have used public transit in both cities, and they will get you to your destination much cheaper than other transit options. My last trip to LA I used a combination of Uber and public transit and that seemed to work pretty well for what I needed, but in the past I have usually rented a car there (although that has it's own issues - parking in LA can be a real pain!!!).
Another thing to keep in mind is that while most public transit systems around the world will allow you to purchase with more than just cash - not all of them take credit card - which is a major pain because when I'm traveling I rarely carry cash let alone coins. Edmonton's public transit does NOT take credit card (unless you purchase a pass from a vendor or online and not from one of the stand alone machines in the LRT stations).
It is also almost always cheaper to buy in bulk when you purchase tickets. You can get a 10 pass or a month long pass in Edmonton for example and save quite a bit over purchasing individual tickets.
There are also some cities (Paris for example), where you can purchase a pass that allows you to access museums and other attractions as well as public transit - they can often be bought in 1 to 7 day passes - and can be worth it if they include many of the attractions that you plan to visit. They are generally not worth it if there's only a couple things included that you plan to check out.