Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Data Type Issue
#1
Hi Team,

I am facing issue while executing the below code
row_1 = ['Facebook', 0.0, 'USD', 2974676, 3.5]
row_2 = ['Instagram', 0.0, 'USD', 2161558, 4.5]
row_3 = ['Clash of Clans', 0.0, 'USD', 2130805, 4.5]
ratings_1=row_1[3]
ratings_2=row_2[3]
ratings_3=row_3[3]
total=(ratings_1+ratings_2+ratings_3)
Average=(total/3)
print(Average)

 
The error says "average isn’t defined in your code, but we expected it to be float type"

Can you please help me as how to convert the output of a variable into a float datatype.
Thanks
Rahul Kaushik
Reply
#2
The code looks executable. Did you run your code using some web-service
which produces such specific errors? Note, Python is case sensitive, may be you need to use average.
Reply
#3
Hi Scidam,

Thanks a lot , yeah I corrected the case sensitive part and it worked.

Once again Thanks.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020