The insight is that print(*range(1, n+1)) prints all numbers from to N separated by spaces. The * unpacks the range into separate arguments. But we need no spaces. What parameter controls the separator between items?
It's sep. If sep="" (empty string), there's no separator at all. The numbers print directly next to each other: 123 instead of 1 2 3. That's the whole solution: unpack a range into print, set sep to empty string.