From 0972d3714c758a9c5471cb6110624334e2a5f13e Mon Sep 17 00:00:00 2001 From: rick Date: Sat, 11 Dec 2021 03:12:47 +0100 Subject: [PATCH] fix: empty listCadeau + can have yourself for the gift --- app.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app.py b/app.py index c97569c..afc7521 100644 --- a/app.py +++ b/app.py @@ -8,18 +8,18 @@ app = Flask(__name__) listCadeau = {} def genCadeau(): + global listCadeau tmp = list(myconfig.listGens.keys()) for g in myconfig.listGens.keys(): - a, b = random.choices(tmp, k=2) - if a == g: - listCadeau[g] = b - tmp.remove(b) - else: - listCadeau[g] = a - tmp.remove(a) + pc = [v for v in tmp if v != g] + a = random.choice(pc) + listCadeau[g] = a + tmp.remove(a) @app.route('/') def hello(): + if not listCadeau: + genCadeau() return render_template("index.html") @app.route('/code')