'int' object is not iterable
#The error is that here, you need to use i to iterate through a list, but you specified an integer, namely len(sequence), instead of the necessary list ...
for i in len(sequence):
#To iterate through all integers from 0 up to, but not including len(sequence), you can specify the needed list, as follows ...
for i in range(len(sequence)):