You have to use a break statement if the user enters some value. Where the while loop will run and prompt the input message until some value is given by the user. The syntax for while input is not empty in Python.
while True: s = input() if not s: break somelist.append(s)
You can check input is empty or not with the help of the if statement.
x=input() if x: print(x) else: print('empty input')
Run while loop input is not empty in Python
Simple example code.
name = '' # Start a loop that will run until the user give input while True: name = input("Enter Name to exist: ") if name: print(name) break
Do comment if you have any doubts and suggestions on this Python input topic.
Note: IDE: PyCharm 2021.3.3 (Community Edition)
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.
Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.
This does not work in Python 3 it seems. This is my code:
NOMBRE_CLIENTE = str(detalles_cliente(‘Nombre Cliente: ‘))
Even if you enter nothing it breaks out with no errors.