This is the, I am trying to validate a user input whether it is a number or in a given range, but every time it's not in the range or its a word, it creates a new cell to input a number, want to clear the history of previous cells, how?
def validiating_user():
    accepted_range = range(0,10)
    within_ranges = False
    r = 'abcd'
    while r.isdigit() == False or within_ranges == False:
        r = input('Plase input a number(0-10): ')
        if r.isdigit() == False:
            print('Please enter a number,not words')
        if r.isdigit() == True:
            if int(r) in accepted_range:
                within_ranges = True
            else:
                print('Please enter a number in range(0-10)')
    return int(r)
print(validiating_user())

 
     
     
    