In school I was trying to make a tally of cafes people go to. If someone picks something I want to make a variable for it to count tallies for that specific choice. So for example if I had Starbucks and Tim Hortons in my list, the program should store the amount of times I type it in as an answer. I don't want to hardcode anything or use the count method. I have been trying this since I've been assigned but can't figure it out. I am trying to keep the code as beginner friendly as possible.
Here is my code below, and the file I used. Atm I am just trying out these three so I don't need any input. If you could help thanks a lot.
cafes = []
cafename = []
cafeindex = []
value = 0
cafeIndex = -1
with open("responses.csv") as file:
for line in file:
allanswers = line.lower().split(",")
cafes.append(allanswers[2])
cafes.remove(cafes[0])
for cafe in cafes:
if cafe not in cafename:
cafename.append(cafe)
for cafenum in range(cafename):
cafenum = cafenum - cafenum
cafeindex.append(cafenum)
for cafecount in cafes:
cafefind = cafename2.index(cafecount)
cafeindex[cafefind] += 1
print(cafename[cafefind], " = ", cafeindex[cafefind] )
I can't upload a file so I will just have a photo of the contents below. I used excel and the file is called responses.csv.