Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # # total positive & neg
- # x = [1,2,3,-1,-2,4,9,-10]
- # poscount = 0
- # posList = [i for i in x if i > 0] # all postive numbers
- # negList = [i for i in x if i < 0] # all negetive numbers
- # negcount = 0
- # for i in x:
- # if i > 0:
- # poscount += 1
- # if i < 0:
- # negcount += 1
- # print('total positive: ' + str(poscount))
- # finalposList = ''
- # for i in posList:
- # finalposList += str(i) + ', '
- # print('positive numbers: ' + finalposList[:-2])
- # print('total negetive: ' + str(negcount))
- # finalnegList = ''
- # for i in negList:
- # finalnegList += str(i) + ', '
- # print( 'negetive numbers: '+ finalnegList[:-2])
- # total numbers:
- y = '1 2 4 56 9 0'
- covertToList = y.split(' ') # convert to list
- covertListToInt = list(map(int, covertToList)) # convert str list to int list
- totalNum = len(covertListToInt) # length of list
- print(totalNum) # ans : 6 , total 6 numbers in list
Advertisement
Add Comment
Please, Sign In to add comment