jeudi 14 juillet 2016

Trying to create function with if statement iterating w/ list, don't understand

sections = page.select('div.section_number')

def className(x):
    for i in range(0, len(sections)):
        x=x+i
        return

li = ['school name', 'school abrev.', className(sections[0])]

sections returns a long list like:[Acc-900, Acc-1000, Bio-910, Z00-900] Idk how to iterate through the list above so that it runs every time li is printed. It's giving me TypeError: coercing to Unicode: need string or buffer, int found.I think this is saying I can't add x+i due to different datatypes. Other than that all I know is my logic is probably off.

Aucun commentaire:

Enregistrer un commentaire