Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
the title may be misleading, but i didnt know how else to put it.
i was writing a really basic program when i encountered a small problem. my code calculates the average rating of a season.
Python
from __future__ import division


def avgseason():
    x = 0
    c = 1
    sum1 = 0
    a = int(raw_input('number of episodes: '))
    while (x < a):
        b = int(raw_input(("rating",c)))
        sum1 = sum1 + b
        c = c+1
        x = x+1
        average = sum1/a
    return average       


my problem is that when the program asks for the rating of each episode, i prints ('rating', 3) whereas i want it to say 'rating 3'. how should i go about solving this, sorry if this is a really basic question.
Posted
Updated 20-Mar-14 2:36am
v2

Your code reads:

Python
b = int(raw_input(("rating",c)))



whereas, for your desired print statement, it should be:

Python
b = int(input('rating',c))


Just remove the extra pair of brackets, it would go good.
 
Share this answer
 
v2
Comments
Vidhu Shah 20-Mar-14 21:55pm    
I actually tried that at the beginning, but i get an error that says 'TypeError: [raw_]input expected at most 1 arguments, got 2'...
Jalem Raj Rohit 20-Mar-14 23:00pm    
Yeah, raw_input takes only one argument, so if you want to feed in two arguments, you have to use input(), rather than raw_input()
Vidhu Shah 21-Mar-14 6:55am    
im sorry but i have the same problem with input.
Your code looks promising, but I think there's a mistake (I mean not the mistake, might be typing mistake) in this line,
Python
b = int(raw_input(("rating",c)))

So make it,
Python
b = int(raw_input("rating," c))

And still it is not working then, give a try try with this,
Python
b = int(input("rating", c))


-KR
 
Share this answer
 
Comments
Vidhu Shah 21-Mar-14 13:25pm    
I actually tried that at the beginning, but i get an error that says 'TypeError: [raw_]input expected at most 1 arguments, got 2'...

I get the same error with input

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900