[Tutor] why do i get None as output
Roelof Wobben
rwobben at hotmail.com
Mon Sep 6 08:34:35 CEST 2010
Hello,
I have this programm:
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!")
''
"""
word2=""
teller=0
if type(seq) == type([]):
teller=0
while teller < len(seq):
seq[teller]=""
teller = teller + 1
elif type(seq) == 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 I get None as output instead of []
Can anyone explain why that happens ?
Roelof
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100906/d8f131e0/attachment.html>
More information about the Tutor
mailing list