repl.it
@tsimpson1379/

Secret Santa

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import random, replit

END = '\033[0m'
c = {'grey': '\033[90m', 'red': '\033[91m', 'green': '\033[92m', 'yellow': '\033[93m', 'blue': '\033[94m', 'magenta': '\033[95m', 'cyan': '\033[96m', 'white': '\033[97m', 'default': '\033[98m'}

def move(col, row): print("\033["+str(col)+";"+str(row)+"H")

names = []
while True:
    name = input('Enter name: ').title()
    if name == '': break
    names.append(name)
    '''
    elif name == 'undo':
        names.pop()
        print('\033[H\x1b[2K')
    else:
        names.append(name)
        print('\033[H'+c['red'])
        print(END)
    '''

def selectNames(giving):
    receiving = giving[:]
    s = {}
    for name in giving:
        if len(giving) == 1 and giving == receiving:
            return selectNames()
        giveTo = random.choice(receiving)
        while name == giveTo:
            giveTo = random.choice(receiving)
        s[name] = giveTo
        receiving.remove(giveTo)
    return s

s = selectNames(names)

seen = []
while len(seen) != len(names):
    replit.clear()
    print('Welcome to the Secret Santa generator\n=====================================\n')
    name = input('Enter your name: ').title()
    while not name in names:
        print('Are you sure? That name is not in this secret santa! Try again.')
        name = input('Enter your name: ').title()
    if name in seen:
        print('You have already looked at your assigned person!')
        input('Press enter to continue ')
        continue
    print('You need to get a gift for '+s[name]+'. Merry Christmas!')
    seen.append(name)
    input('Press enter to continue (and hide the name!!) ')
?