i want to write a function in python named cont() which sends a message "continue" and which should take no argument
<p>i want to write a function in python named cont() which sends a message "continue" and which should take no argument.the function should print the message yes,y or Y.then return true otherwise false. i have done it but there is an error.</p>

<pre><code>def cont():
    x = input("enter any word of your choice")
    for letter in 'x':
        if letter == '[0]':
            a = input ("continue")
            if a == 'yes' == 'y' == 'Y' :
                continue
            print 'current letter will be:',letter
        else:
            print x

if __name__=="__main__":
    cont()
</code></pre>

<p>Sadly the code that you supplied and the description that you wrote, do not agree with each other. There is no attempt to <code>return</code> any value, indeed, there is nothing to suggest what the decision of <code>True</code> or <code>False</code> would be based upon.<br>
Assuming that you are using python 2.7, this should get you started:</p>

<pre><code>def cont():
    x = raw_input("Enter any word of your choice: ")
    for letter in x:
#    if letter == '[0]':
        a = raw_input ("Continue? ")
        if a == 'yes' or a == 'y' or a == 'Y' :
#            continue
            print 'Current letter will be:',letter
        else:
            print x
            break
if __name__ == '__main__':
    cont()
</code></pre>

<p>I have no idea what you were attempting to do with the <code>if letter == '[0]':</code> or the <code>continue</code> lines, so I have commented them out.
If you wish to return a value, simply <code>return True</code> or <code>return False</code> at the point of your choosing in the code. The other option is to set a variable to <code>True</code> or <code>False</code> and then, as the last statement of <code>cont()</code> use the <code>return</code> keyword with the variable.</p>

<p>Note: if you are using python3 the <code>raw_input</code> becomes <code>input</code> and the <code>print</code> commands become <code>print()</code></p>

python python-2.7 python-3.x