This is the 8852nd most frequent Korean word.
갔는데
"갔는데" means "went, but" or "went, and then" depending on context.
In this sentence, 갔는데 ([I] went, but) is used to indicate a contrast or continuation where the visit to the market leads to the realization of the high prices.
나는 어제 시장에 갔는데 물건이 너무 비쌌어요.
I went to the market yesterday, but the items were too expensive.
Here, 갔는데 ([I] went, and) is used to connect the event of going to the park with the observation of a crowded park.
공원에 갔는데 사람들이 많이 있었어요.
I went to the park, and there were many people.
In this case, 갔는데 ([I] went, but) implies an unexpected situation where the intention to visit the restaurant faces a closing.