I don’t understand why the while keeps executing even though I have written the name "gabriel" or the name "tommy"
nombre = ""
while nombre != "gabriel" or nombre !="tommy":
nombre = input()
if nombre != "gabriel" or nombre != "tommy":
print("ingrese su nombre nuevamente")
else:
print("su nombre es ")
break
>Solution :
You are using or where you should be using and. However, you are also making two checks where you only need one, and initializing nombre unnecessarily. Consider this instead:
while True:
nombre = input()
if nombre != "gabriel" and nombre != "tommy":
print("ingress su nombre nuevamente")
else:
print("su nombre es", nombre)
break
or using or correctly:
while True:
nombre = input()
if nombre == "gabriel" or nombre == "tommy":
print("su nombre es", nombre)
break
print("ingress su nombre nuevamente")