- 1

I cant get this to work... Ive been at this for hrs n n idk y its not working...

#function takes in two integers and return a list of prime numbers between those two integers def list_of_primes(intlow,inthigh): plist=[] for i in range(intlow,inthigh+1): prime=True for j in range(2,i): if i%j==0: prime=False if prime==True: plist.append(i) return plist #use input to get lower and higher integers from the user #call the function list_of_primes using the user values for the lower and higher integers and save the result to a variable called primelist #print primelist #print the first 4 elements of primelist (if there are fewer than four elements it should display the entire list) #using a for loop calculate the sum of the elements of primelist, print that sum

27th Nov 2018, 4:07 PM
Paci
9 Antworten
+ 1
I just tried to call your function, it seems to work (except that you should not accept numbers below 2). What's the error message?
27th Nov 2018, 4:16 PM
HonFu
HonFu - avatar
+ 1
Ah - have you forgotten to actually call your function? Below your definition for example: print(list_of_primes(2, 100))
27th Nov 2018, 4:21 PM
HonFu
HonFu - avatar
0
It keeps telling me no output...
27th Nov 2018, 4:19 PM
Paci
0
Yeah I think I'm just gonna have to start from scratch...lol I can't get this ...thank u though...
27th Nov 2018, 4:30 PM
Paci
0
Huh? What are you talking about? This code works!!! Have you googled it?
27th Nov 2018, 4:38 PM
HonFu
HonFu - avatar
0
No I didn't ..n it keeps telling me no output
27th Nov 2018, 4:40 PM
Paci
0
Yo...I put it in the wrong place......I got it to output....
27th Nov 2018, 4:42 PM
Paci
0
And what was it then about having to do this from scratch?
27th Nov 2018, 4:47 PM
HonFu
HonFu - avatar
0
Well my teacher told us that in python everything had to be lined up or it won't work...so I figured maybe It wasn't lined up right...but yeah...lol thank u..
27th Nov 2018, 4:50 PM
Paci