Skip to content

Instantly share code, notes, and snippets.

@mbiemann
Last active November 12, 2021 22:32
Show Gist options
  • Save mbiemann/1731789ba927ef5c3aecc69f68ef8672 to your computer and use it in GitHub Desktop.
Save mbiemann/1731789ba927ef5c3aecc69f68ef8672 to your computer and use it in GitHub Desktop.
Game Of Thrones - Election Single Random Voting
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