Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- userFile = input('File: ')
- positiveSum = 0
- negativeCount = 0
- openedUserFile = open(userFile, "r")
- openedEvenFile = open("even.txt", "w")
- openedOddFile = open("odd.txt", "w")
- for line in openedUserFile:
- line = int(line)
- if line % 2 == 0 or line == 0:
- positiveSum += line
- evenLine = line
- evenLine = str(line)
- openedEvenFile.write(evenLine)
- else:
- oddLine = line
- oddLine = str(line)
- openedOddFile.write(oddLine)
- for line in openedUserFile:
- line = lint.split
- line = int(line)
- if line > 0:
- negativeCount += line
- print('\nThe sum of the positive numbers:', positiveSum)
- print('The count of the negative numbers:', negativeCount)
- #openedUserFile.close()
- openedEvenFile.close()
- openedOddFile.close()
- ## RESULTS
- ## userfile/samplefile.txt:
- ## 2
- ## -1
- ## 0
- ## 6
- ## -23
- ## 1
- ## 62
- ## even.txt result: 20662
- ## odd.txt result: -1-231
- ## positiveSum result: 70
- ## negativeCount result: 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement