In Hesiod’s Works and Days, hope remained inside Pandora’s container after she opened it.
Hesiod describes Pandora as releasing evils into the world when she opened the vessel Zeus had given her. The text then says that only elpis remained inside. Elpis is usually translated into English as “hope,” although the Greek word can also involve expectation or anticipation.
The story does not straightforwardly say that Pandora deliberately trapped hope for humanity. It says that the lid was replaced before elpis escaped. This has led to several interpretations: hope may be a comfort left for humans, or it may be another force held back from them. The ambiguity comes from the ancient wording and from later retellings.
The familiar phrase “Pandora’s box” is itself a translation error from later tradition. Hesiod describes a large storage vessel, not a small box. The story is part of a wider Greek explanation for why suffering exists among humans.