python Return value none
<p>I need some clarification. When I execute the below code with the function using <code>return</code>, I am getting different behavior from when I use the function using <code>print</code>. I am getting the same output but it is printing a word "none" which is not in the program.</p>

<pre><code>import random 

# **With Return**   
def getAnswer(answerNumber): 
    if answerNumber == 1: 
        return 'It is certain' 
    elif answerNumber == 2: 
        return 'It is decidedly so' 
    elif answerNumber == 3: 
        return 'Yes' 

# **With Print**    
def getAnswer2(answerNumber):
    if answerNumber == 1:
        print('It is certain')
    elif answerNumber == 2:
        print('It is decidedly so')
    elif answerNumber == 3:
        print('Yes')

r = random.randint(1, 3) 
fortune = getAnswer(r) 
print(fortune)

fortune = getAnswer2(r) 
print(fortune)
</code></pre>

<p>The output is for example</p>

<pre><code>Yes
Yes
None
</code></pre>

<p>Every Python function implicitly returns <code>None</code>, unless you explicitly return something else.</p>

<p>In your first section, you are explicitly returning the string, and printing that value.</p>

<p>In your second section, you are printing the message, and then printing the return value (<code>None</code>, implicitly).</p>

python python-2.7