python - Counting factors in a list? -



python - Counting factors in a list? -

okay made list called numberslist, variable number = 20, count = 0, , spot = 0.

numberslist = range(1, 11) number = 20 count = 0 spot = 0.

i want count numbers in list go 20. tried this:

while spot <= len(numberslist): if(number % int(numberslist[spot]) == 0): count = count + 1 spot = spot + 1 print count

but keeps saying list index out of range. please help!

your index goes far @ lastly iteration of while loop. alter <= < , should work:

while spot < len(numberslist):

or utilize for loop:

for in numberslist: if number % == 0: count += 1

python list count

Comments

Popular posts from this blog

javascript - mongodb won't find my schema method in nested container -

How do you set up a perforce server to work over the internet? -

ios - Lagging ScrollView with UIWebview inside -