I have 2 lists: first is list that I need to work with and the second is list of -1. First of all I need to find the remainder of the divison of the number (number is len(lst)) and put it to the position (remainder of the divisor) in the list of -1. If there is already element, then to the next position in the list (if the next position is not empty, to the next and so on until it finds a position). How to realize the part that is in bold?
# -*- coding: utf-8 -*-
def fun(lst):
count = [-1] * (len(lst) + 1)
jar = []
for i in range(len(lst)):
jar.append(lst[i]%(len(lst) + 1))
if count[jar[i]] == -1:
count[jar[i]] = jar[i]
else:
arv[jar[i] + 1] = jar[i] # problem starts here
print jar
lst = [26, 53, 12, 65, 39, 6]
lst = fun(lst)
arv? (where problem starts?)lst[i] % len(lst)? If you are potentially getting floats in the input list, I assume math.ceil would be better.