human
Find the date after next half year from a given date | Function to find the date after the next half - year.
Stores the number of days in the months of a leap year.
List of months.
Days in half of a year.
Index of current month.
Starting day.
Decrement the value of cnt by 1.
Increment cur_date.
If cnt is equal to 0 , then break out of the loop.
Update cur_month.
Update cur_date.
Print the resultant date.
Driver Code.
Function Call"
How can the above be solved in Python?
assistant
#Here is code to find the date after next half year from a given date and the other steps required.
 def getDate ( d , m ) :
	days = [ 31 , 29 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31 ]
	month = [ ' January ' , ' February ' , ' March ' , ' April ' , ' May ' , ' June ' , ' July ' , ' August ' , ' September ' , ' October ' , ' November ' , ' December ' ]
	cnt = 183
	cur_month = month . index ( m )
	cur_date = d
	while ( 1 ) :
		while ( cnt > 0 and cur_date <= days [ cur_month ] ) :
			cnt -= 1
			cur_date += 1
		if ( cnt == 0 ) :
			break
		cur_month = ( cur_month + 1 ) % 12
		cur_date = 1
	print ( cur_date , month [ cur_month ] )
D = 15
M = " January "
getDate ( D , M )