Correct sentence:
"I was playing the piano for 3 hours yesterday."
This uses the past continuous (was playing) + duration (for 3 hours), and it’s fine.
Here's why:
The past continuous describes an action that was in progress at a specific time in the past.
The phrase “for 3 hours” gives us the duration of the activity.
“Yesterday” gives us the time reference.
So, you're saying: At some point yesterday, I was in the middle of playing the piano, and it lasted 3 hours.
🟡 Alternative – also correct:
"I played the piano for 3 hours yesterday."
This uses the past simple to describe a finished action and is more direct.
Use this if you’re just telling someone what you did, without focusing on it being in progress.
🟠 Would past perfect work?
"I had been playing the piano for 3 hours..."
This form (past perfect continuous) is only correct if you're setting up another event afterward, like:
I had been playing the piano for 3 hours when the neighbors complained.
So it requires a second event to justify the past perfect.
In summary:
"I was playing the piano for 3 hours yesterday." Correct. Focuses on the action in progress.
"I played the piano for 3 hours yesterday." Also correct. More direct.
"I had been playing..." Only use if it connects to another past event.