Perfect Square function that doesn't return
<p>I'm a beginner working with Python and I was given this task: <em>write a function which returns the highest perfect square which is less or equal to its parameter (a positive integer).</em></p>

<pre><code>def perfsq(n):

    x = 0
    xy = x * x
    if n &gt;= 0:
        while xy &lt; n:
            x += 1

        if xy != n:
            print (("%s is not a perfect square.") % (n))
            x -= 1
            print (("%s is the next highest perfect square.") % (xy))
        else:
            return(print(("%s is a perfect square of %s.") % (n, x)))
</code></pre>

<p>When I run the code to execute the function it doesn't output anything. I'll admit, I'm struggling and if you could give me some advice on how to fix this, I would be grateful.</p>

<pre><code>def perfsq(n):

    x = 0
    xy = x * x
    if n &gt;= 0:
        while xy &lt; n:
            x += 1
            xy = x*x &lt;-- Here

        if xy != n:
            print (("%s is not a perfect square.") % (n))
            x -= 1
            xy = x*x  &lt;--Here
            print (("%s is the next highest perfect square.") % (xy))
        else:
            print(("%s is a perfect square of %s.") % (n, x)) &lt;--And here
</code></pre>

<p>Think about that. </p>

python loops if-statement