programming question

I want it to ask for the level, then once I input one it prints the level.

#include <LiquidCrystal.h> //import lcd library
#include <Keypad.h> //import keypad library

LiquidCrystal lcd(5, 4, 3, 2, 1, 0); //lcd pins
const byte ROWS = 4; // four rows
const byte COLS = 4; // four columns

//define the keymap
char keys [ROWS] [COLS] = {
  {'1', '4', '7', 'X'},
  {'2', '5', '8', '0'},
  {'3', '6', '9', '='},
  {'+', '-', '*', '/'}
};
byte rowPins[ROWS] = {
  9 ,8 ,7 ,6}; //connect keypad ROW1, ROW2, ROW3, ROW4 to these arduino pins
byte colPins[COLS] = {
  13, 12, 11, 10}; //connect keypad COL1, COL2, COL3, COL4 to these arduino pins

//create the keypad
Keypad myKeypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

int number1;
int number2;
int operation;
int level;
int answer;

void setup(){
 
  
 // while (operation && level == 0) {
  //delete the char
  char key = NO_KEY;
  level = 0;
  lcd.begin(16,2);
  lcd.clear();
  //delete the lcd.begin
  lcd.print("set level");
  lcd.setCursor(0,1);
  lcd.print("1-3");
  while(level == 0);
  key = myKeypad.getKey();
  if (key != NO_KEY && (key=='1'||key=='2'||key=='3')){
    level = (key - 48);
  }
  lcd.clear();
  lcd.print(level);
  delay(10000);
}
void loop(){
  
}

It works but when I try and input a level it does… nothing
can you please help?

while(level == 0);

A while with a semicolon is an empty while loop. This says, while level is equal to 0 do nothing. Doing nothing is not going to change the fact that level is equal to 0. So this is an infinite loop and your program i hung right there. Did you mean to have all that next bit of code that gets a new value for level inside that while loop? If so then you need to go learn about the { and } and what they are for.

getKey() is NOT a blocking function. It will NOT wait for a key to be pressed, so you have a value for level. There is a different method that will waitForKey().

    level = (key - 48);

Not obvious.

    level = (key - '0');

Obvious.

Thanks to both of you, that worked perfectly