If you want to practice even more then you could enter wonderful world of recursion.
One way of sum list elements:
One way of sum list elements:
>>> def sum_of_list_elements(lst): ... if not lst: ... return 0 ... else: ... return lst[0] + sum_of_list_elements(lst[1:])
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.