In Python, write a code that validates user inputs. First, create a program that lists the menu of the drinks you sell. It then asks users to input the drink they want to order. After submitting an order, your program confirms the order with the user.
```python
menu = {
1: "Frappuccino",
2: "Cafe Latte",
3: "Cafe Americano",
4: "Cafe Macchiato"
}
def validate_input():
while True:
try:
order = int(input("Please enter your order (1-4): "))
if order in menu:
print("You've ordered", menu[order] + ". Your order will be ready soon.")
break
else:
print("Invalid input. Please enter a number from 1 to 4.")
except ValueError:
print("Invalid input. Please enter a number.")
validate_input()
```
Make sure you validate user inputs in the code:
- User input should not be empty.
- User input should not raise a ValueError (the input can be converted to an integer).
- User can only input 1, 2, 3, or 4.