Advertisement
TornioSubito

Ricorsione_somma lista di interi e check pari/dispari

Jun 16th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. def checkSum(list):
  2. #@param list : list
  3. #@return bool (vero per lista vuota o se somma= numero pari, falso se somma= numero dispari)
  4. if len(list)==0:
  5. return 'vero'
  6. elif len(list)==1:
  7. global sum
  8. sum=list[0]
  9. if sum%2==0:
  10. return 'vero'
  11. else:
  12. return 'falso'
  13. else:
  14. n=list.pop(0)
  15. funcInt(list)
  16. sum=sum+n
  17. if sum%2==0:
  18. return 'vero'
  19. else:
  20. return 'falso'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement