Since "hope" and "expect" both translate as esperar, how would you say something like "It was better than I expected, but not as good as I had hoped" in Spanish?
It's true that both
In most sentences you will only want to use one of the meanings, and it'll be quite clear which one you're meaning...
In this case, as you want to use both meanings, you'd better use synonyms, something like:
I would nominalize either "expect" or "hope"; the former goes to expectativa, the latter to esperanza (context dependent). So:
Or with some freedom: