Wrong output while trying to display count of .tsv file?

Wrong output while trying to display count of .tsv file?
0.0 0

#1


This code is returning 0 while trying to display constituency(particular city) from ls2014.tsv
Failed to trace out error.Any help.
thank you,


#2

@vamsipenmetsa7 I have executed the below code in lab and got out put.

PFA for reference

image

def election(state,constituency):
     count = 0
     for i in state:
         if (i.split("\t")[1] == constituency):
             count += 1
     return count

state=open("ls2014.tsv").read().splitlines()
election(state, "Anandpur Sahib")

#3

showing 0 for some constituencies like Adilabad and Karimnagar ?


#4

The data is having many tabs in between each field. thats causing the issue in output count function.

thanks