I have a file that has following data format:
0
65
88
11
0
11
11
I tried to write below code in order to create a dictionary that the keys are the sequences from 1 to EOF and the values are the data in the file: The code I wrote so far is:
hash_1 ={}
#print(hash_1)
file = open('t30.dat','r')
while True:
data =file.readline()
if not data:
break
print(int(data.strip()))
#hash_1[int(data.strip())] += 1
The problem is the last line that I cannot figure it out how to do this
hash_1[int(data.strip())] += 1
My desired output should be :
hash_1= {1:0,2:65,3:88,4:11,5:0,6:11,7:11}
Any help would be appreciated