Riju21

14_practice2

Mar 27th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. # # total positive & neg
  2.  
  3. # x = [1,2,3,-1,-2,4,9,-10]
  4. # poscount = 0
  5. # posList = [i for i in x if i > 0]   # all postive numbers
  6. # negList = [i for i in x if i < 0]  # all negetive numbers
  7. # negcount = 0
  8.  
  9. # for i in x:
  10. #     if i > 0:
  11. #         poscount += 1
  12. #     if i < 0:
  13. #         negcount += 1
  14.  
  15. # print('total positive: ' + str(poscount))
  16.  
  17. # finalposList = ''
  18. # for i in posList:
  19. #     finalposList += str(i) + ', '
  20. # print('positive numbers: ' + finalposList[:-2])
  21.  
  22. # print('total negetive: ' + str(negcount))
  23.  
  24. # finalnegList = ''
  25. # for i in negList:
  26. #     finalnegList += str(i) + ', '  
  27. # print( 'negetive numbers: '+ finalnegList[:-2])
  28.    
  29.  
  30. # total numbers:
  31.  
  32. y = '1 2 4 56 9 0'
  33. covertToList = y.split(' ')  # convert to list
  34. covertListToInt = list(map(int, covertToList))  # convert str list to int list
  35. totalNum = len(covertListToInt)  # length of list
  36. print(totalNum)                 # ans : 6 , total 6 numbers in list
Advertisement
Add Comment
Please, Sign In to add comment