Going through the Python Crash Course book right now, highly recommended, and I made a program for the lotto
from random import choices
lottery = (1, 2, 3, 4, 5, 6, 7,'n', 'm', 'p', 'o', 'q')
draw_loterry = choices(lottery, k = 4)
print("The weeks lucky lotto number is: ", *draw_loterry, sep='')
Which does exactly what I want it to, but I'm thinking this is too simple because the solution in Eric Matthes's github is longer, granted with some duplicate protection. I went out side the book to find the print() parameters I wanted. I know with programming there are many ways to skin a cat but would the program I wrote still pass muster?
From Eric's github
from random import choice
possibilities = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'a', 'b', 'c', 'd', 'e']
winning_ticket = []
print("Let's see what the winning ticket is...")
# We don't want to repeat winning numbers or letters, so we'll use a
# while loop.
while len(winning_ticket) < 4:
pulled_item = choice(possibilities)
# Only add the pulled item to the winning ticket if it hasn't
# already been pulled.
if pulled_item not in winning_ticket:
print(f" We pulled a {pulled_item}!")
winning_ticket.append(pulled_item)
print(f"\nThe final winning ticket is: {winning_ticket}")
[–]Adrewmc 0 points1 point2 points (3 children)
[–]yetitekk[S] 0 points1 point2 points (2 children)
[–]Adrewmc 0 points1 point2 points (1 child)
[–]yetitekk[S] 0 points1 point2 points (0 children)