def draw_letters(): """Pick NUM_LETTERS letters randomly. Hint: use stdlib random""" k = min(NUM_LETTERS, len(POUCH)) draw = random.sample(POUCH, k) for letter in draw: POUCH.remove(letter) return draw
def draw_letters(num_letters): letters = [] for _ in range(num_letters): idx = rd.randint(0, len(POUCH)) letters.append(POUCH[idx]) POUCH.remove(POUCH[idx]) return letters
def draw_letters(): """Pick NUM_LETTERS letters randomly. Hint: use stdlib random""" letters = [] for i in range(NUM_LETTERS): draw = random.choice(POUCH) POUCH.remove(draw) letters.append(draw) return letters
def draw_letters(): """Pick NUM_LETTERS letters randomly. Hint: use stdlib random""" draw = [] for num in range(NUM_LETTERS): rand_choice = POUCH.pop(random.choice(range(len(POUCH)))) draw.append(rand_choice) return draw
def draw_letters(): # pull letters from bag my_letters = [] for i in range(7): position = random.randint(0, len(POUCH) - 1) # print(i, position, POUCH[position]) my_letters.append(POUCH.pop(position)) return my_letters
def draw_letters(): """Draw 7 letters from POUCH""" me_pouch = list() pouch_len = len(POUCH) for _ in range(0, 7): position = random.randint(0, pouch_len - 1) me_pouch.append(POUCH.pop(position)) pouch_len = pouch_len - 1 return me_pouch
def draw_letters(): letters = [] for count in range(1, 8): letter = random.choice(POUCH) # Got a letter, need to remove it from POUCH so same letter is not drawn 2x for x in POUCH: if letter == x: idx = POUCH.index(x) del POUCH[idx] break letters.append(random.choice(POUCH)) # Check if drawn letters are only vowels, redraw if so if _all_vowels(letters): print('Only vowels, repicking...') draw_letters() print("Letters drawn: {}".format(' '.join(letters))) return letters
def draw_letters(): return [POUCH.pop().lower() for x in range(NUM_LETTERS)]
def draw_from_pouch(n): """Pop n randomly chosen letters out of pouch.""" shuffle(POUCH) for _ in range(n): yield POUCH.pop()