def median(scores):
    """Returns the median of only valid scores in the given list [0,100]"""

    # Checks and adds valid scores to valid_scores
    valid_scores = []
    for score in scores:
        if not(score < 0 or score > 100):
            valid_scores.append(score)

    if len(valid_scores) == 0:
        return -1

    half = len(valid_scores) // 2
    # Return avg of 2 middle scores if even
    if len(valid_scores) % 2 == 0:
        return (valid_scores[half] + valid_scores[half - 1]) / 2

    # Otherwise return middle score for odd
    return valid_scores[half]