Last active
May 3, 2020 22:33
-
-
Save juanpenia/70f8f0c165f0236ef2208c66c14ac9dd to your computer and use it in GitHub Desktop.
Make a Draw!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# importing ~~cars~~ modules! | |
from random import sample | |
from time import sleep | |
# fancy drawing thing | |
def DrawMessage(): | |
print("\nDrawing", end = "", flush = True) | |
for i in range(3): | |
sleep(0.7) | |
print(".", end = "", flush = True) | |
def main(): | |
# variables | |
list = [] | |
# intro? | |
print("================================================================") | |
print("========================= Make a draw! =========================") | |
print("================================================================\n") | |
# reading participants | |
print("Enter participants: ") | |
p = input("NOTE: Enter \"-\" after the last participant. \n\n") | |
while(p != "-"): | |
list.append(p) | |
p = input() | |
# let's draw! (if there are participants, duh) | |
if(len(list) > 0): | |
# let's ask how many people will win this raffle! (we will use p because we are stingy as f**k!) | |
while True: | |
p = int(input("\nEnter number of winners: ")) | |
if((p > 0) and (p < len(list))): | |
break | |
print("ERROR: Number is invalid. Please, enter a correct number.") | |
# drawing... | |
DrawMessage() | |
w = sample(list, p) | |
if(p == 1): | |
print("\n\nThe winner is " + w[0] + ". Congratulations!") | |
else: | |
print("\n\nThe winners are: \n") | |
j = 1 | |
for i in w: | |
msg = "{0}. {1}" .format(j, i) | |
print(msg) | |
j += 1 | |
print("\nCongratulations!") | |
else: | |
print("\nNo participants have been entered.") | |
# goodbye! | |
input("\nPress Enter to exit.") | |
# go! | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment