0
Create a function in python where it will collect multiple values in to a function and find out each value is prime or not
def primeornot(*l): for num in l : if num>1: for i in range(2,num): if(num%i)==0: break else: print(num,"is prime number") return print(primeornot(3,4,5,7,11,12)) But it is showing only 3 is a prime number....i want that to execute all the prime numbers among that
4 Respuestas
+ 5
change the call to return with a break statement. When you return inside of a function, that function ends.
AND no need to call print(primeornot(...)) because inside the function you have calls to print.
so just:
primeornot(...)
will be acceptable and it won't print None.
https://code.sololearn.com/c6AnM39xIL6M/?ref=app
0
Tq
0
But function should have return know must and should then here in this code we didnt mentioned return
0
It SHOULD do whatever it's gotta do to give the correct or percieved output. That's what it does