Python Forum
How to calculate a months' 1st, 4th, 7th day and also 1st again?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to calculate a months' 1st, 4th, 7th day and also 1st again?
#1
Hi everyone, I just started how to learn to code.
I am trying to write a program that should count the days an athlete decides to run once every three days for the whole year
(On the 1st, 4th, 7th ... day of each month).
At the beginning of a new month, he always runs on the 1st day of the month, even if three days have not passed since his last run.


for x in range(1,32,3):
    print(x)
This is the code I wrote for counting every three days but I couldn't find a solution for how to add the first days of months.
A little help with this would be perfect. Rolleyes
Reply
#2
A bit more information would be helpful. What is this program supposed to do? Does it pop up a message to let you know you are going to run today? Does it generate a list of days when you are going to run? Is there anything that you enter to run the program? Do you tell it what the month is or does it print out a schedule for the entire year?

What is wrong with [1,4,7,10,13,16,19,22,25,28] and maybe 31. Is the "maybe 31" part where you are having difficulty?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to calculate the year by adding n months? pav1983 19 5,879 Jun-27-2020, 08:27 PM
Last Post: pav1983
  how to tell python to do something every 6 months Jezani_VIII 1 2,025 Aug-18-2019, 02:30 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020