[Tutor] where is this returning from??
Reed L. O'Brien
reed at intersiege.com
Wed Aug 25 15:47:44 CEST 2004
OK silly question. I am going throught a book about Python so I can
learn it. Following (loosely) the book I made a script. When I run it
all is as expected. Exept when calling the first branch of the if
statement that calls chantTwice that calls printTwice. It always returns
the appropriate answer followed by \n None (outputbelow script). I can
seem to find where it is getting none from!! Can someone tell me what I
am missing so I can move on. I just am not seeing it.
#!/usr/local/bin/python
p1 = 'this is part one'
p2 = 'this is part two'
verb = 'run'
noun = 'home'
nickname = 'abode'
feeling = 'home sweet home'
alien = 'work'
name = raw_input("What next?\n")
#name = input(prompt)
def printTwice(output):
print output, output
def chantTwice(p1,p2):
cat = p1 + p2
printTwice(cat)
def thought(name):
if name == noun:
print chantTwice(p1, p2)
elif name == verb + ' ' + noun:
print feeling
elif name == nickname:
print 'The most beautiful place ever is my ' + nickname
else:
print 'I want to be home!!!'
thought(name)
%python why.py
What next?
home
this is part onethis is part two this is part onethis is part two
None
--
4.6692016090
'cmVlZEBpbnRlcnNpZWdlLmNvbQ==\n'.decode('base64')
More information about the Tutor
mailing list