Используйте %
оператор для создания модуля:
notes[note % len(notes)]
Демонстрация:
>>> notes = ["a", "a#", "b", "c", "c#", "d", "e", "f", "f#", "g", "g#"]
>>> note = 21
>>> notes[note % len(notes)]
'g#'
или в цикле:
>>> for note in range(22):
... print notes[note % len(notes)],
...
a a# b c c# d e f f# g g# a a# b c c# d e f f# g g#
Следующее должно сделать трюк:
var userQuery = firebase.database().ref('users').orderByChild('rank').equalTo(4);
userQuery.once('value', function(snapshot) {
snapshot.forEach(function(childSnapshot) {
var childKey = childSnapshot.key;
var childData = childSnapshot.val();
console.log(childKey);
console.log(childData);
});
});