generate functionTue, 21 Feb 2023

The date of a certain day is characterized by two natural numbers: m (serial number of the month) and n (number). According to the entered m and n (in one line separated by a space), determine: a) the date of the previous day (assume that m and n do not characterize January 1); b) the date of the next day (assume that m and n do not characterize December 31). The problem is to assume that the year is not a leap year. Print the previous date and the next date (in the format: mm.dd, where m is the day of the month; d is the number of the day) in one line separated by a space. P.S. Number of days in non-leap year months starting from January: 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 Sample Input: 8 31 Sample Output: 08.30 09.01

def date(m, n): if m == 12 and n == 31: return '01.01' if n == 1: return str(m - 1).zfill(2) + '.31' return str(m).zfill(2) + '.' + str(n - 1).zfill(2) + ' ' + str(m).zfill(2) + '.' + str(n + 1).zfill(2) print(date(*map(int, input().split())))

Questions about programming?Chat with your personal AI assistant