My code is:
import time
local_time = time.localtime()
time_string_d = time.strftime("%d", local_time)
time_string_m = time.strftime("%m", local_time)
time_string_y = time.strftime("%Y", local_time)
time_string_hm = time.strftime("%H:%M", local_time)
day_st = ['1', '21', '31']
day_nd = ['2', '22', '32']
day_rd = ['3', '23']
day_th = ['4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18',
'19', '20', '24', '25', '26', '27', '28', '29', '30']
def month():
if time_string_m == '1':
print('It is ' + time_string_hm)
print('January ', day())
if time_string_m == '2':
print('It is ' + time_string_hm)
print('February ', day())
if time_string_m == '3':
print('It is ' + time_string_hm)
print('March ', day())
if time_string_m == '4':
print('It is ' + time_string_hm)
print('April ', day())
if time_string_m == '5':
print('It is ' + time_string_hm)
print('May ', day())
if time_string_m == '6':
print('It is ' + time_string_hm)
print('June ', day())
if time_string_m == '7':
print('It is ' + time_string_hm)
print('July ', day())
if time_string_m == '8':
print('It is ' + time_string_hm)
print('August ', day())
if time_string_m == '9':
print('It is ' + time_string_hm)
print('September ', day())
if time_string_m == '10':
print('It is ' + time_string_hm)
print('October ', day())
if time_string_m == '11':
print('It is ' + time_string_hm)
print('November ', day())
if time_string_m == '12':
print('It is ' + time_string_hm)
print('December ', day())
else:
print('There was an error in the month detecting system.')
def day():
if time_string_d in day_st:
print('st')
if time_string_d in day_nd:
print('nd')
if time_string_d in day_rd:
print('rd')
if time_string_d in day_th:
print('th')
else:
print('There was an error in the day detecting system.')
and I want it to print the following:
It is (current time for example: 14:20)
(current month for example: October, current day + /st/nd/rd/th for example 8th)
Like this:
It is 14:20
October 8th
Also if it fails then the following:
There was an error in the month detecting system
or
There was an error in the day detecting system.
What it actually prints out:
It is 14:20
There was an error in the day detecting system.
October None
There was an error in the month detecting system.