Blue Week Special Offer | Brighten your week!
days
hours
minutes
seconds

Apps_data error

Screen Link:
https://app.dataquest.io/m/313/conditional-statements/9/the-else-clause

My Code:

""" opened_file = open('AppleStore.csv')
from csv import reader
read_file = reader(opened_file)
apps_data = list(read_file)

for app in apps_data[1:]:
    price = float(app[4])
    if price == 0.0:
        app.append('free')
    else :
        app.append('non free')
apps_data[0].append('free_or_not')
print(apps_data[:6]) """

What I expected to happen:

What actually happened:

apps_data      error

Hi @KhaledHanafy: you did not initialise free_or_not as an empty list thus it is throwing an error. The list should be initialised before the loop

I tried to run your code.
It’s a classic case of typo (and it happens all the time with programmers) :stuck_out_tongue:

DQ system is expecting a ‘-’ between non and free

app.append(“non-free”)

instead of

app.append(‘non free’)

thank you for your help, i thought it would be ok since its a string but i guess not.

I haven’t understand that why we must write down as “non-free”?

Hi @cem.ayhan,
It is basically for Data Quest answer checking system. The answer checking system looks for an exact match for things given in the instruction. Though “Non Free”, “Non free”, “Non_Free” and “Non-free” all looks the same, but for a machine, they all are different. I hope this clarifies.

2 Likes