""" By Brian Tomasik (https://briantomasik.com/). First published: 2018-06-29. Last update of any kind: 2019-11-16T23-41. To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty. This script was built with Python 3.6. Hopefully it should work for later versions of Python 3 also. # Description Given a starting date, this program computes successive dates that are N, 2*N, 3*N, etc days after the starting date. For example, if the starting date is 2018 Mar 27, and if N = 10, the program would print out the date 10 days from then (2018 Apr 06), 20 days from then (2018 Apr 16), and so on. This is useful if you have a recurring reminder and need to know what the dates are for it. While I've only written this program to work when N is measured in days, you could easily modify it for N measured in weeks, months, etc. """ from datetime import datetime, timedelta def main(): date = input("Enter a starting date in the format yyyy-mm-dd, such as 2018-02-01: ") parsed_date = datetime.strptime(date, "%Y-%m-%d") every_N_days = int(input("Now enter the number of days between dates. For example, if you want to print out dates every 10 days, enter 10. ")) assert every_N_days > 0, "every_N_days has to be > 0." num_to_print = int(input("Finally, enter how many successive dates you want printed out. For example, 50. ")) assert num_to_print > 0, "num_to_print has to be > 0." next_datetime = parsed_date for i in range(num_to_print): next_datetime = next_datetime + timedelta(days=every_N_days) print(next_datetime.strftime('%Y %b %d')) if __name__ == "__main__": main()