Skip to content

Instantly share code, notes, and snippets.

@jjsanderson
Created February 23, 2017 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jjsanderson/eb7c16c68251c23fa8e66149040ab243 to your computer and use it in GitHub Desktop.
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.
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