Created
February 23, 2017 16:41
-
-
Save jjsanderson/eb7c16c68251c23fa8e66149040ab243 to your computer and use it in GitHub Desktop.
Not sure this is a totally sane way of structuring the data, but … what can I say, I like dictionaries.
This file contains hidden or 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 random | |
hearts = { | |
"QR001": [5, 38], | |
"QR002": [15, 60], | |
"QR004": [0, 00], | |
"QR005": [3, 92], | |
"QR093": [0, 92] | |
} | |
print hearts["QR002"] | |
# OK, so we have a dictionary of QR references, each with a list datastructure of index number and heart rate. Or something like that. | |
# This will output the index associated with a QR reference: | |
print hearts["QR002"][0] | |
# And this, the heart rate: | |
print hearts["QR002"][1] | |
# Can then check if we have this QR code logged: | |
print "QR005" in hearts | |
print "QR003" in hearts | |
emptylist = [] | |
for key, val in hearts.items(): | |
if (val[0] == 0): | |
emptylist.append(key) | |
print emptylist | |
select = random.choice(emptylist) | |
hearts[select][0] = "TADA!" | |
print hearts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment