davegimo

Untitled

May 27th, 2022
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. def verifica(l,k):
  2.  
  3. for i in range(len(l)): #mi scorro la lista
  4. if len(l) - k >= i: #check per evitare negli ultimi elementi di stampare cose fuori dalla lista
  5. if aux(l,k,i) == True: #aux: funzione ausialiaria
  6. return True
  7. return False
  8.  
  9.  
  10. def aux(l,k,i):
  11. for x in range(k):
  12. if l[i] != l[i+x]:
  13. return False
  14. return True
  15.  
  16.  
  17. def printaux(l,k,i): #solo di prova
  18. print("i = " + str(i))
  19. for x in range(k):
  20. print(l[i+x])
  21.  
  22.  
  23. l = [1,1,1,2,5,6,7,8]
  24. print(verifica(l,3))
  25.  
Advertisement
Add Comment
Please, Sign In to add comment