Mar-22-2017, 01:54 PM
(This post was last modified: Mar-22-2017, 02:12 PM by sparkz_alot.)
hello everyone, im a soldier and in my unit there is a lot of guard duty which means that everyday each soldier have a 3 hours guard duty which he takes care of an a specific area.
there is a specific guy which makes the list of the guards keeping time and what im trying to make is a program which make that list automatic without a man manualy making it.
there is 2 areas that sometimes your guard there sometimes there so here is what i made for now :
sorry about my english...its not my home language so..
there is a specific guy which makes the list of the guards keeping time and what im trying to make is a program which make that list automatic without a man manualy making it.
there is 2 areas that sometimes your guard there sometimes there so here is what i made for now :
from random import *
guards = [] #here there is the names of all the available guards!
newguards = []
guardscount = input('How many guards guard?:')
for i in range(0,int(guardscount)):
i = input('What is the guard name:?')
guards.append(i)
guardians = {}
times = ['23:00-2:00','00:00-03:00','02:00-05:00','03:00-06:00','05:00-08:00','06:00-09:00','08:00:11:00','09:00-12:00',
'11:00-14:00','12:00-15:00','14:00-17:00','15:00-18:00','17:00-20:00','18:00-21:00','20:00-23:00','21:00-00:00']
day = 21
month = 3
index = 15
while day < 23:
for x in guards:
guardians[x] = times[randint(0, index)]
times.remove(guardians[x])
index -= 1
if index == 0 :
print('Today', day, '/', month, 'This is the Guardians List:', guardians)
times = ['23:00-2:00','00:00-03:00','02:00-05:00','03:00-06:00','05:00-08:00','06:00-09:00','08:00:11:00','09:00-12:00',
'11:00-14:00','12:00-15:00','14:00-17:00','15:00-18:00','17:00-20:00','18:00-21:00','20:00-23:00','21:00-00:00']
index = 15
day += 1
if len(guards) == 0:
guards = newguards
newguards = []
continuethe problem i have here is that somehow the if index =0 statment apply even when index is not 0 i dont know why..sorry about my english...its not my home language so..
Moderator:
sparkz_alot: removed formating from code
