ive been stock in this and i'm also new to this so i often use for loops, is there an easy way to do this, also its not printing values correctly. I want to print all the values that is not in rese list. The problem is when a line has a same date (example the 14-Thu is repeated) it prints out (14-Thu #3 13 14 15 16 17 18 and 14-Thu #3 8 18) the (14-Thu #3 8 18) should'nt be there. and also same as other dates when they are in same line.
rese = [14-Thu #3 admin 7 8 9 10 11 12 13,14-Thu #4 admin 9 10 11 12 13,14-Thu #5 admin 9 10 11 12 13 ,15-Fri #5 admin 9 10 11 12 13]
temp = ''
tt= ''
for i in range (1,pc_no+1):
pcp.append('#'+str(i))
for i in range(7): # each days in a week
date = datetime.datetime.today() + datetime.timedelta(days=i)
temp_d = str(str(int(date.strftime('%d'))) + '-' + date.strftime('%a'))
week_.append(temp_d)
for i in rese:
word = i.split()
for j in week_:
temp = ''
if word[0] == j:
for k in pcp:
#print (k)
if k == word[1]:
#print (k,'in')
for h in range(ot_,ct_+1):
if str(h) not in word:
if temp != '':
temp = temp+' '+str(h)
else:
temp = tt+' '+str(h)
tt=''
if h == ct_:
print ('')
res_.append(j+' '+k+' '+temp)
elif str(h) in word:
if temp != '':
temp = temp +' '+str(h)
res_.append(j+' '+k+' '+temp)
temp = ''
else:
tt = str(h)
else:
x = j+' '+k+' '+str(ot_)+' '+str(ct_)
res_.append(x)
else:
for i in pcp:
x = j + ' ' + i + ' ' + str(ot_) + ' ' + str(ct_)
res_.append(x)
Aucun commentaire:
Enregistrer un commentaire