Python : Basic countdown timer & function() > int()
<p>I'm trying to ucreate a timer function that runs in the background of my code and make it so I can use/check the time. What I mean by use/check, I'm trying to make it so I can call upon that timer function and use it as integer.</p>

<p>This is the code I currently have:</p>

<pre><code>def timer():
    for endtime in range(0, 15):
        print(15 - endtime)
        time.sleep(1)

def hall():
    timer()
    while (timer &gt; 0):
       do something
</code></pre>

<p>Currently only using <code>print(15 - endtime)</code> for confirmation it is counting down.</p>

<p>But what the code does now is execute the countdown and that's it, it never touches the while loop. And of course the last issue is I can't set a function to an int. So I'm looking for some way where I can check where the timer is at and use it in that while loop.</p>

<pre><code>import time

def timer(tim):
    time.sleep(1)
    print tim

def hall():
    tim = 15
    while (tim &gt; 0):
        print 'do something'
        timer(tim)
        tim-=1
</code></pre>

<p>Not the cleanest solution, but it will do what you need.</p>

python timer