def count(coll):
    """
    Returns the number of items in the collection. Also works on strings.
    """
    if hasattr(coll, "__len__"):
        return len(coll)

    n = 0
    for _ in coll:
        n += 1
    return n