#!/usr/bin/env python3 """london_bridge.py Plays the game of London Bridge @author Richard White @version 2018-03-01 """ from atds import Queue from random import * song = ["London Bridge is falling down", "falling down", "falling down", "London Bridge is falling down", "My Fair Lady", "Take the key and lock her up", "lock her up", "lock her up", "Take the key and lock her up", "My Fair Lady"] people = ["Mustafa","Audrey","Sean","Pranay","Eli","Mr. White","Ms. Dunham","Mr. Silvester"] q = Queue() # How to put the people into the queue in random order? ''' while len(people) > 0: q.enqueue(people.pop(randrange(len(people)))) ''' shuffle(people) for person in people: q.enqueue(person) # Let's start playing the game line_counter = 0 song_length = len(song) while not q.isEmpty(): verse = line_counter % song_length print(song[verse], end=' ') line_counter += 1 person = q.dequeue() print("[" + person + "]") if line_counter % 5 == 0: if q.isEmpty(): print(person + " wins!") else: print(person + " is out!") else: q.enqueue(person)