Create a While True loop that calls for input until the input differs from the empty string to check input enter pressed or not in Python.
You can also use a simple if statement with the input value. If Text is empty then it means enter has been pressed by the user.
Example get know user input enter pressed in Python
Simple example code check user will hit enter and you will check if it was entered or not.
guess = "" while True: if guess == "": guess = input("Please Enter a letter! ") else: break print(guess)
Detect Enter has pressed
text = input("type in enter") # or raw_input in python2 if text == "": print("you pressed enter") else: print("you typed some text before pressing enter")
type in enter
you pressed enter
Do comment if you have any doubts or suggestions on this Python input topic.
Note: IDE: PyCharm 2021.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.