Advertisement
rahat14

Rakib`s code

Nov 20th, 2020
610
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. lst =[]
  2. flst=[]
  3. slst=[]
  4. n=input()
  5. lst = [int(x) for x in str(n)]
  6. length = len(n)
  7. if (length % 2) == 0:  
  8.     #this is a even list  
  9.     flst = lst[:len(lst)//2]
  10.     slst = lst[len(lst)//2:]
  11.    
  12. else:  
  13.    #not even so remove the middle man
  14.     removed = lst.pop(int((length/2)))
  15.     flst = lst[:len(lst)//2]
  16.     slst = lst[len(lst)//2:]
  17.  
  18.    
  19. #we divided the list into 2 smaller lst now we implement logic
  20. #1st half element sum
  21. fsum = sum(flst)
  22. #2nd half element sum
  23. ssum = sum(slst)
  24. print(fsum)
  25. print(ssum)
  26. if(fsum==ssum):
  27.     print("you have won the lottery")
  28. else :
  29.     print("you lost")
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement