def shuffle(self, x, random=None, int=int):
\"\"\"x, random=random.random -> shuffle list x in place; return None.
Optional arg random is a 0-argument fu
Clearly you're passing in d.keys() to your shuffle function. Probably this was written with python2.x (when d.keys() returned a list). With python3.x, d.keys() returns a dict_keys object which behaves a lot more like a set than a list. As such, it can't be indexed.
The solution is to pass list(d.keys()) (or simply list(d)) to shuffle.