Advertisement
TornioSubito

checkValue (problema 2 esercitazione)

Jun 18th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. def checkValue(L,V,k):
  2. #@param L : list
  3. #@param k : int
  4. #@return bool
  5. if L==[]:
  6. return 'inserire una lista non vuota'
  7. elif (len(L)-1)<k:
  8. return L[0]==V or (L[1]==V and L[0]==V)
  9. elif (len(L)-1)%k==0:
  10. if L[len(L)-1]==V:
  11. return checkValue(L[0:-1],V,k)
  12. else:
  13. return False
  14. else:
  15. return checkValue(L[0:-1],V,k)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement