If number is less than 0 (or blank), estim won't be defined, so calling it would be an error. I'm not sure why you're defining it anyway, just use a while loop directly:
def main(): number = int(input("Insert the number:")) if number == "": print("Goodbye!") elif number < 0: print("Error: negative number") else: estimation = 1 while True: estimation = (estimation + number / estimation) / 2 tollerance = 0.000000001 difference = abs(number - estimation **2) if difference <= tollerance: break number = estimation return number