It is not working properly | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

It is not working properly

num = int(input()) def prime(num): flag = False if num > 1: for i in range(2,num): if num % i !=0: flag = True break if flag is True: print(f"{num} is a prime") else: print(f"{num} is not a prime") prime(num) This is not telling me if a number is prime or not

19th Aug 2021, 10:17 AM
Tarun
5 Answers
+ 3
You didn't give proper indention. As python is fully based on indention. Plz make your indention proper. Then surely your code may work perfectly
19th Aug 2021, 10:22 AM
Aysha
Aysha - avatar
+ 3
Give 4 spaces or simply give a tab it will work fine. Try it once again!!
19th Aug 2021, 10:24 AM
Aysha
Aysha - avatar
+ 1
Even if it printed, it would result in False for x <= 2 and True otherwise
19th Aug 2021, 10:58 AM
Angelo
Angelo - avatar
+ 1
You need to write prime function before the if else statement then it may work fine
19th Aug 2021, 1:23 PM
Aysha
Aysha - avatar
0
Please give the proper indention It would be so helpful
19th Aug 2021, 10:23 AM
Tarun