My code is very similar to the solution. However, I am getting the following message:
What is the difference? I do not see it. Thank you!
“”" ##### MY CODE###### “”""
opened_file = open(‘AppleStore.csv’)
from csv import reader
read_file = reader(opened_file)
apps_data = list(read_file)
def freq_table(column):
dictionary = {}
for element in apps_data[1:]:
idk = element[column]
if idk in dictionary:
dictionary[idk] += 1
else:
dictionary[idk] = 1
return freq_table
ratings_ft = freq_table(7)
####VARIABLES######
ratings_ft ()
-
actual + expected
-
[undefined]
- {‘0.0’: 929,
- ‘1.0’: 44,
- ‘1.5’: 56,
- ‘2.0’: 106,
- ‘2.5’: 196,
- ‘3.0’: 383,
- ‘3.5’: 702,
- ‘4.0’: 1626,
- ‘4.5’: 2663,
- ‘5.0’: 492}
read_filereader (<class ‘_csv.reader’>)
<_csv.reader at 0x7fa0675b6898>
apps_data
listtype (<class ‘type’>)
list
opened_fileTextIOWrapper (<class ‘_io.TextIOWrapper’>)
<_io.TextIOWrapper name=‘AppleStore.csv’ mode=‘r’ encoding=‘UTF-8’>
####MESSAGE#######
ratings_ft isn’t defined in your code, but we expected it to be dict type
SOLUTION
opened_file = open(‘AppleStore.csv’)
from csv import reader
read_file = reader(opened_file)
apps_data = list(read_file)
def freq_table(index):
frequency_table = {}
for row in apps_data[1:]:
value = row[index]
if value in frequency_table:
frequency_table[value] += 1
else:
frequency_table[value] = 1
return frequency_table
ratings_ft = freq_table(7)