Last active
November 12, 2021 22:32
-
-
Save mbiemann/1731789ba927ef5c3aecc69f68ef8672 to your computer and use it in GitHub Desktop.
Game Of Thrones - Election Single Random Voting
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
import json, random | |
# load candidates file | |
candidates = json.load(open('candidates.json','r')) | |
# numbers of candidates | |
total_of_candidates = len(candidates) | |
# generate a random number | |
voting = random.randint(1,total_of_candidates) | |
# get the name of chosen candidate (array starts with zero) | |
chosen = candidates[voting-1] | |
print(f'The chosen candidate is "{chosen}".') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment