Jump to content

Python Issues

Go to solution Solved by TRINHbot1101001,

Well it's been a while since I used python, but you could do something like:

 

 

t=0

while t>=0:

        print("\a")

        time.sleep(0.5)

        t+=1

 

t is just a variable for time, so as long as your program is running, t is counting, and this loop continues

Hello,

 

I am trying to make a basic reminder programme in Python that makes a noise every 20 minutes reminding me to do something.

 

I would like the programme to repeat it's self every 20 minutes, but I dont want to copy and paste the code a bunch of times to make it do this. I would like the code to make it automatically do this.

 

The code:

# 27th of January 2015# Imports the time moduleimport time# Tells the user what is going to happenprint (" The programme will make a noise every 20 minutes reminding you to do your task")# Sets the timer for 20 minutestime.sleep(1200)# Makes the alert(s) (THIS IS THE CODE I WANT TO REPEAT)print("\a")time.sleep(0.5)print("\a")time.sleep(0.5)print("\a")time.sleep(0.5)print("\a")# Asks the user to press enter to exit the programmeinput("\n\nPress the enter key to exit")

P.S - I have only just started on Python, and I know that there is better ways to do this. But I am trying to make my first useful programme that I will actually use.

 

 

 

Thanks in advance,

 

- Harry

It seems impossible until it's done.

Link to comment
https://linustechtips.com/topic/299320-python-issues/
Share on other sites

Link to post
Share on other sites

Well it's been a while since I used python, but you could do something like:

 

 

t=0

while t>=0:

        print("\a")

        time.sleep(0.5)

        t+=1

 

t is just a variable for time, so as long as your program is running, t is counting, and this loop continues

Link to comment
https://linustechtips.com/topic/299320-python-issues/#findComment-4064920
Share on other sites

Link to post
Share on other sites

Well it's been a while since I used python, but you could do something like:

 

 

t=0

while t>=0:

        print("\a")

        time.sleep(0.5)

        t+=1

 

t is just a variable for time, so as long as your program is running, t is counting, and this loop continues

Thankyou, you have been a great help :)

It seems impossible until it's done.

Link to comment
https://linustechtips.com/topic/299320-python-issues/#findComment-4065040
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×