Help please


#1

Hi, I am new to any type of programming and python is my first language. I am trying to write a program to Implement a Grade System using List( i have to use list only)
with following operations:
Add (name, grade) into the database, Output all records in the database with grades sorted
Output the average grade and max grade of the database
Find a record using name , Find records using grade

I have written this till now
database = [] # Global List
while 1:
name = raw_input('Enter name:')
grade = raw_input('Enter grade:')
if name == 'ok':
break
database.append((name, grade))
print database.sort(key=lambda b: b[1])
............................

output (tuple)

[('tom', '50'), ('mk', '45')]

.......Now i need to calculate the average and max grade, I know how to calculate the average but dont know how to change grade '50' to integer 50

Please help and suggest
**I am using python 2.7


#2

@textace97047,
google search
== discussions / opinions == ( about 4 million programmers use this )
python convert string to integer site:stackoverflow.com
= http://stackoverflow.com/questions/642154/how-to-convert-strings-into-integers-in-python

== the Book ==
builtin-functions site:python.org
https://docs.python.org/2/library/functions.html


#3

Thanks, but, just solved it by isolating the second element from tuple, assigning it a var and then converting it to int.