def greedy_cow_transport(cows,limit=10):
    """
    Uses a greedy heuristic to determine an allocation of cows that attempts to
    minimize the number of spaceship trips needed to transport all the cows. The
    returned allocation of cows may or may not be optimal.
    The greedy heuristic should follow the following method:

    1. As long as the current trip can fit another cow, add the largest cow that will fit
        to the trip
    2. Once the trip is full, begin a new trip to transport the remaining cows

    Does not mutate the given dictionary of cows.

    Parameters:
    cows - a dictionary of name (string), weight (int) pairs
    limit - weight limit of the spaceship (an int)
    
    Returns:
    A list of lists, with each inner list containing the names of cows
    transported on a particular trip and the overall list containing all the
    trips
    """ 
    # Sorting through sorted, and using for with two variables to iterate simultaneously.
    # The lambda function indicates that we will sort by the value of each item
    # Only works in Python 3.7+
    """
    cowsCopy =  {k: v for k, v in sorted(cows.items(), key=lambda item: item[1], reverse = True)}
    while(len(cowsCopy)):
        trip = []
        totalCost = 0
        for key,value in cowsCopy.items():
            if totalCost + value <= limit:
                trip.append(key)
                totalCost+=value
                
        #Delete cows selected form the dict
        for key in trip:
            del cowsCopy[key]
        
        result.append(trip)
    """
    
    # Older python versions
    trips = []
    cowsCopy = cows.copy()
    sortedCows = sorted(cowsCopy.items(), key=lambda x: x[1], reverse = True)
    while sum(cowsCopy.values()) > 0:
        ship = []
        total = 0
        for cow, value in sortedCows:
            if cowsCopy[cow] != 0 and value + total <= limit:
                ship.append(cow)
                total += value
                cowsCopy[cow] = 0
        trips.append(ship)
    return trips