Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- # List of kids
- kids = ['Davidson', 'Gabrielle', 'Shane']
- # Initializes iteration variables
- # "itvar" determines when the while loop will stop
- itvar = 0
- # "three" determines when the loop is at the end of one day
- three = -1
- # "daily" is a list that changes with every iteration
- # It will be appended to three times (once per kid) and then be reset
- # There is no way it can have a duplicate name
- daily = []
- # This while loop will execute as long as "itvar" is less than 31
- # You can make it execute more by changing this number
- while itvar < 31:
- # If the "three" variable has been incrememted (three times) to 2
- # it will be reset to -1 and the "daily" list will be emptied
- if three == 2:
- three = -1
- daily = []
- # Generates a random number
- rand = random.randint(0,2)
- # This if statement is there so there can be no duplicate names in the "daily" list
- # It tests if the name at the random index of "kids" is already in the list
- # If a name is successfully appended the "three" variable will be incremented
- if kids[rand] not in daily:
- three += 1
- daily.append(kids[rand])
- # This if statement only runs if the "three" variable is at it's last value (2)
- if three == 2:
- # The iteration variable is incrememted here
- # This is the variable that only allows this program to print out 31 times
- itvar += 1
- # This just prints dashes for formating along with the iteration variable
- print "---------------" + str(itvar)
- # This for loop prints out all the names in the "daily" list
- for kid in daily:
- print kid
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement