Develop a Python script that connects to a Redis database, stores user input as key-value pairs, and retrieves values based on given keys.
PLAINFORMAT
import redis

# Connect to the Redis server
r = redis.Redis(host='localhost', port=6379, db=0)

def store_key_value():
    key = input("Enter the key: ")
    value = input("Enter the value: ")

    # Store the key-value pair in the Redis database
    r.set(key, value)
    print(f"Key '{key}' and its corresponding value '{value}' have been stored.")

def get_value_by_key():
    key = input("Enter the key to retrieve its value: ")

    # Retrieve the value from the Redis database
    value = r.get(key)

    if value is not None:
        print(f"The value for key '{key}' is '{value.decode('utf-8')}'.")
    else:
        print(f"No value found for key '{key}'.")

if __name__ == "__main__":
    while True:
        print("\n1. Store key-value pair")
        print("2. Get value by key")
        print("3. Exit")

        choice = int(input("Enter your choice: "))

        if choice == 1:
            store_key_value()
        elif choice == 2:
            get_value_by_key()
        elif choice == 3:
            break
        else:
            print("Invalid choice. Please try again.")