1st Dec 2021, 2:09 PM
Mayank
6 Answers
0
Make the loop stop after detecting non-prime by inserting a break statement in line 6. Lines 7, 8 should be unindented by one level to make it a for/else statement. Then delete line 9.
1st Dec 2021, 2:55 PM
Brian
Brian - avatar
+ 1
Please always tag the language you're asking about. https://code.sololearn.com/W3uiji9X28C1/?ref=app
1st Dec 2021, 7:42 PM
Simon Sauter
Simon Sauter - avatar
0
Yes. Else part executed if if-part fails. 9%2==0 is false then print and breaks Find logic of printing else only when never if part executed.
1st Dec 2021, 2:36 PM
Jayakrishna 🇼🇳
0
Just iterate ur code by giving value 9 u will find ur mistake
1st Dec 2021, 6:45 PM
Pranshu Sachan
0
Ident or move break statement into if-block. Its correctly outside if.
2nd Dec 2021, 3:55 PM
Jayakrishna 🇼🇳
0
Add an else: continue block to check the next values before getting to the break statement. https://code.sololearn.com/cI7YSZ0hVttm/?ref=app Also try not to use "no." as an abbreviation for number, because it is easily confused with no, specially in small phone screens. There is a module called primefac that you can pip install and does prime factorization if that is what you want. More ways of checking if a number is prime: https://www.pythonpool.com/check-if-number-is-prime-in-JUMP_LINK__&&__python__&&__JUMP_LINK/
3rd Dec 2021, 4:15 AM
Bob_Li
Bob_Li - avatar