jeudi 16 novembre 2017

if statement is skipped python

I have this piece of code,

n=p
k=s
c=-1
l=[i+1 for i in range(n)]

while len(l) >1: 
  if c==k:
     c=0
  else:
     c+=1
  t=len(l)
  if t>=k:
   for s in range(k-c-1,int(t/k),k-1):
    print(l[s],s,k,c)
    del l[s]

and when i run it the c adds up to 2 before the second if statement works, i don't know why it doensnt go through if c is either 0 or 1 or less.my question is, why isnt it working if the condition in the if statement is true? thanks in advance

Aucun commentaire:

Enregistrer un commentaire