Struggling with some basic code

Im a beginner with any form of coding and im trying to solve a problem but the lightbulb has not switched on just yet...

ive managed to scramble the code below to allow me to do part of what I wanted but im struggling with the data input side.

Basically I want to add something to the code below but im not sure where to put it at present. I would like the user to be prompted for a number (get int possible to use?) between 1-50 which will then return the suitable output (the number inputted would denote the number of rows) but I want to include a loop to ensure that if I dont enter a number between 1-50 it just goes back to the start and asks again.

Apologies if im not making much sense, its a simple problem but im just not seeing where I can put the code or how to exactly construct it.