*I AM TRYING TO CALCULATE THE AVARAGE IN AMY VIEW, I ADDED A VARIABLE 
CALLED average TO HOLD THE RESULTS OF THE AVAERAGE CALCULATIONS BUT I KEEP 
GETTING THIS ERROR:<type 'exceptions.NameError'> name 'average' is not 
definedI DONT UNDERSTAND WHAT I'M DOING WRONG!!!HERE IS MY CODE:{{extend 
'layout.html'}}..............................<table><tr>    <th>Term</th>  
  <th>Subject</th>    <th>Mark Acquired</th>    <th>Total Mark</th>    
<th>(%) Acquired</th>    <th>Grade</th>    <th>Teacher's 
Comment</th></tr>{{for report in form:        
perc=(float(report.marks)/float(report.total))*float(100)                if 
perc>=75:            grade='A'        elif perc>=65:            grade='B'  
      elif perc>=55:            grade='C'        elif perc>=45:            
grade='D'#THE CALCULATION FOR AVARAGE IS DONE HERE         average+=perc    
                }}{{pass}}                                    <tr>          
  <td>{{=report.term.term}}</td>            
<td>{{=report.subject.subject_name}}</td>        
<td>{{=report.marks}}</td>    <td>{{=report.total}}</td>              
<td>{{=perc}}(%)            </td>            <td>{{=grade}}</td>            
</td>        <td>{{=report.comments}}</td>        </tr><tr>    <td>#THE 
VARIABLE IS CALLED HERE        {{=average}}    </td></tr>      
 {{pass}}{{pass}}<br />    
</table>....................................................I AM 
REFERENCING A VARIABLE THAT HAS VALUES AND I THOUGHT IN PYTHON WE DO NOT 
DECLARE VARIABLES LIKE IN OTHER LANGUAGES, WHY I AM GETTING THIS 
ERROR???!!!!*

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to