More than one for-loop in a python while-loop -



More than one for-loop in a python while-loop -

i'm python/coding newbie , i'm trying set 2 loops while loop? can this? how can print out dictionary mydict create sure doing correctly?

i'm stuck.

40 minutes later. not stuck anymore. everyone!

def runloop(): while uid<uidend: row in soup.findall('h1'): try: name = row.findall(text = true) name = ''.join(name) name = name.encode('ascii','ignore') name = name.strip() mydict['name'] = name except exception: go on row in soup.findall('div', {'class':'profile-row clearfix'}): try: field = row.find('div', {'class':'profile-row-header'}).findall$ field = ''.join(field) field = field.encode('ascii','ignore') field = field.strip() except exception: go on try: value = row.find('div', {'class':'profile-information'}).findal$ value = ''.join(value) value = value.encode('ascii','ignore') value = value.strip() homecoming mydict mydict[field] = value print mydict except exception: go on uid = uid + 1

runloop()

on nested loops:

you can nest , while loops before python give error, it's bad form go more 4 deep. create function if find needing lot of nesting. utilize fine though.

some problems code:

it never reach print statements because under first loop have homecoming statement. when python sees homecoming within function, leave function , nowadays homecoming value. i avoid using seek , except until understand why you're getting errors without those. make sure indentation consistent. maybe it's re-create , paste error, looks indentation of lines character more others. create sure every tab 4 spaces. python, unlike languages, freak out if indentation off. not sure if didn't post function call, need phone call runloop() utilize function.

python for-loop while-loop

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -