def user_input(parameter):
    """
    Ask user how many hours they want to dedicate to a certain activity and assigns
    it to the variable commitment.
    """
    commitment = input("Input many hours would you like to commit to: " + parameter + ".\n")
    try: 
        commitment = float(commitment)
        if commitment >= 0 and commitment <= 24:
            print("You've elected to dedicate", commitment, "hours to", parameter)
            print("")
            return commitment
        else:
            print("You can't commit less than 0 hours or more than 24 hours to an activity. Try again.")
            print("")
            return user_input(parameter)
    except ValueError:
        print("You didn't input a number. To make this work, you need to input something like '10' to represent 10 hours. Let's try again")
        print("")
        return user_input(parameter)