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?
I have struggle with this part of lesson it gives me an Error which my answer isn’t according to value that they expect
I though if “row” work maybe “col” work too , and that was true but result didn’t change
opened_file = open('AppleStore.csv')
from csv import reader
read_file = reader(opened_file)
apps_data = list(read_file)
games_social_ratings = []
games_social_ratings_rate=[]
for row in apps_data[1:]:
rating = float(row[7])
genre = row[11]
# Complete code from here
if genre == 'Social Networking' or 'Games':
games_social_ratings.append(genre)
for row in apps_data[1:]:
rating = float(row[7])
genre = row[11]
if genre == 'Social Networking' or 'Games':
games_social_ratings_rate.append(rating)
rate_sum = sum(games_social_ratings_rate)
print(len(games_social_ratings))
C_games_social_ratings = []
for col in apps_data[1:]:
C_rating = float(col[7])
C_genre = col[11]
if C_genre == 'Social Networking' or 'Games':
C_games_social_ratings.append(C_rating)
#C_rating = sum(C_rating)
#print(sum(C_rating))
print (len(C_games_social_ratings))
print (rate_sum)
avg_games_social=sum(games_social_ratings_rate)/len(games_social_ratings)
print(avg_games_social)
#avg_games_social = sum(C_rating)/len(games_social_ratings)
#print(avg_games_social)"""
for app in apps_data[1:]:
price = float(app[4])
# Complete code from here
if price == 0:
app.append(‘free’)
elif price > 0 and price < 20:
app.append(‘affordable’)
elif price >= 20 and price < 50:
app.append(‘expensive’)
elif price >= 50:
app.append(‘very expensive’)
apps_data[0].append(‘price_label’)
print(apps_data[:5])
My question is: how does the app.append(‘free/affordable/expensive etc.’) line affect the apps_data variable?
the print at the end shows that apps_data is being appended to, but when using the append function I am referring to the variable “app”. Shouldn’t the code be apps_data.append(‘free/affordable/expensive/very expensive’)? If not, why does app.append make changes to apps_data? Thank you so much for the help!