Python If, Else, Elif Statements: Multiple Conditions

[Screen Link: ]

(Learn data science with Python and R projects)

ratings =
for row in apps_data[1:]:
rating = float(row[7])
price = float(row[4])

^ this is the answer. why is the ‘s’ in ratings not consistent?, and the code still works.

if i standardise and include ‘s’ for all ratings, the code is wrong.

thank you for the help. :slight_smile:

Hi @DebbieTan

ratings and rating are not the same.

The variable ratings is a list here, and the variable rating stores one float value at a given time.

Think of it like a train car/carriage. rating is one train car. Attaching multiple cars like this one after the other makes one long train (ratings).

You first extract the eight element from each row in the apps_data list via this code:

 rating = float(row[7])

# for example
1st row has a rating of ‘5.0’
2nd row has a rating of ‘4.5’
3rd row has a rating of ‘4.0’

Then append this element to the ratings list via this code:

ratings.append(rating)

You will end up with a list like this.

> print(ratings)
> ['5.0', '4.5', '4.0']
2 Likes

hello! ah okay i understand.

just to clarify-

  1. is python able to identify the extra ‘s’ as the code to make it one ‘long train’?
    meaning to say, if i were to use two different words
    e.g. long train (points), carriage (rating), would it be able to execute the same result?

@DebbieTan

Show me the whole code with points/ carriage etc. that you would write for me to answer that.