```python
def is_valid_parenthese( str1):
    """
    Checks if a string of parentheses is valid.
    """
    stack = []
    mapping = {")": "(", "}": "{", "]": "["}

    for char in str1:
        # If the character is a closing bracket
        if char in mapping:
            # Pop the topmost element from the stack if it's not empty.
            # Otherwise, assign a dummy value '#' to top_element.
            top_element = stack.pop() if stack else '#'

            # The mapping for the opening bracket in our dictionary and the
            # top element of the stack should be the same.
            if mapping[char] != top_element:
                return False
        else:
            # If it's an opening bracket, push it onto the stack.
            stack.append(char)

    # In the end, if the stack is empty, then we have a valid expression.
    # The stack won't be empty for cases like "(((".
    return not stack
```