# -*- coding: iso-8859-2 -*-
def sum(l):
    '''Sečte posloupnost prvků
    
    Použití:
        >>> sum([1, 2, 3])
        6
        >>> sum([])
        0
        >>> sum(['a', 2, 3])
        Traceback (most recent call last):
            ...
        ValueError: bad sequence
    '''
    try:
        s = l[0]
        for i in l[1:]:
            s+=i
        return s
    except IndexError:
        return 0
    except TypeError:
        raise ValueError, 'bad sequence'

if __name__ == '__main__':
    import doctest
    doctest.testmod()