def parse_user_input(string_from_user, selected_scramble):
    """Parses the scramble from the user

    >>> parse_user_input("3X3 5", None)
    ('3x3', 5)
    >>> parse_user_input("5", "3x3")
    ('3x3', 5)
    >>> parse_user_input("RU 3", "MEGAMINX")
    ('RU', 3)
    >>> parse_user_input("SQUARE ONE 10", "4x4")
    ('SQUARE ONE', 10)
    >>> parse_user_input("", "3x3")
    ('3x3', 1)
    >>> parse_user_input("5", "4x4")
    ('4x4', 5)
    """
    parts = string_from_user.split()
    if len(parts) == 0:
        if selected_scramble is None:
            raise RuntimeError("You haven't selected a scramble!")
        else:
            return selected_scramble, 1
    if parts[0] in ['2X2', '3X3', '4X4', '5X5', '6X6', '7X7']:
        parts[0] = parts[0].lower()
    count = 1
    try:
        count = int(parts[-1])
        parts.pop()
    except ValueError:
        pass
    if selected_scramble is not None and len(parts) == 0:
        return selected_scramble, count
    return ' '.join(parts), count
