Dad’s short answer: Long enough to do a full room without unplugging, and longer than you'd need for a vacuum. You're moving slowly in overlapping passes with a hose that may need to reach further still, so a short cord is disruptive in a way it isn't with a vacuum.
Working out the number
Measure from the outlet you'd use to the furthest corner of your biggest carpeted room, then double it. That's your minimum — the machine has to get there and come back.
Then add for the hose. If you plan to use the built-in hose on stairs, the machine sits at the bottom and the hose reaches up, so the cord has to get the machine close enough to begin with.
Most decent uprights are generous here because manufacturers know the job. It's the budget end where you find short cords, and it's a real quality-of-life difference.
On extension cords
These machines draw real current, particularly ones with a heater. A thin household extension cord can overheat, and some manufacturers specifically advise against using one at all — worth checking your manual rather than assuming.
If you genuinely need one, use a heavy-gauge cord rated for the load, keep it as short as practical, and don't run it under a rug where heat can't escape.
The better answer is to buy the right cord length in the first place, the same as with a corded vacuum. It's one of the few specs you can calculate exactly before you spend anything.
Dad’s Take: Measure your biggest carpeted room and double it. And check the manual before reaching for an extension cord on a heated machine.