'Copy a read program into a write program Python
def SpecialCharacter():
'opening read file'
with open('CS210_Project_Three_Input_File.txt', 'r') as f:
groceries = f.read().splitlines()
frequencies = {}
for grocery in groceries:
if grocery not in frequencies:
frequencies[grocery] = 0
frequencies[grocery] += 1
for grocery in frequencies:
print(grocery, frequencies[grocery])
I am trying to take the above modified read file and copy it to the below write file.
with open('frequency.dat','w') as wf:
for line in f:
wf.write(line)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
