["python","user-input","default-value"]
How to define default value if empty user input in Python?

Here I have to set the default value if the user will enter the value from the keyboard. Here is the code that user can enter value: input = int(raw_input("Enter the inputs : ")) Here the value will be assigned to a variable input after entering the value and hitting Enter. Is there any method that if we don't enter the value and directly hit the Enter key, the variable will be directly assigned to a default value, say as input = 0.025?
Python 3: inp = int(input('Enter the inputs: ').strip() or "42") Python 2: inp = int(raw_input('Enter the inputs: ').strip() or "42") How does it work? If nothing was entered then input/raw_input returns empty string. Empty string in Python is False, bool("") -> False. Operator or returns first truthy value, which in this case is "42". This is not sophisticated input validation. It's slightly more robust with the addition of .strip(). That handles the possibility of the user entering spaces or other whitespace, which then would be True.