Hello,
I have made this program as solution to a exercise from thinking like a computer scientist. def encapsulate(val, seq): if type(seq) == type(""): return str(val) if type(seq) == type([]): return [val] return (val,) def insert_in_middle(val, seq): middle = len(seq)/2 return seq[:middle] + encapsulate(val, seq) + seq[middle:] def make_empty(seq): """ >>> make_empty([1, 2, 3, 4]) [] >>> make_empty(('a', 'b', 'c')) () >>> make_empty("No, not me!") '' """ if type(element) == type([]): for word2 in seq : word2 = "" elif type(element) == type(()): tup2 = list (seq) while teller > tup2.len(): tup2[teller]="" teller = teller + 1 seq = tuple(tup2) else: seq = "" test = make_empty([1, 2, 3, 4]) print test But now Im getting this error message : Traceback (most recent call last): File "C:\Users\wobben\workspace\oefeningen\src\test.py", line 33, in <module> test = make_empty([1, 2, 3, 4]) File "C:\Users\wobben\workspace\oefeningen\src\test.py", line 21, in make_empty if type(element) == type([]): NameError: global name 'element' is not defined What went wrong here ? Roelof
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor