This function arranges a list of number. If we try z= [4, 4, 2 ] the result will be after some steps 4,3,2,1 but my list is z = [ 1, 1] and I want if a cycle of number coming up again and again the main program will discover it and print this is a cycle before it takes 25 steps.
My conditions are following:
if ordna(z)== z:
elif z==ordna(z)and ordna (z)==z:
see my code
def ordna(x):
b = 0
y = []
for j in x:
new_j = j-1
if new_j<0:
del new_j
else:
y.append(new_j)
b+=1
y.append (b)
y.sort()
y.reverse ()
return y
z=[1,1]
if __name__ =="__main__":
for k in range (0,25):
if ordna(z)== z:
print " Ok"
break
elif z==ordna(z)and ordna (z)==z:
print 'plying round'
break
else:
z=ordna(z)
print " ".join (map(str,z))
if z!=ordna(z) and k==24:
print"Not OK"
Thanks for help and tips!