I am a beginner in python. But I am not getting why I am still getting an error. I use to work in MATLAB, now I need to learn python for my Internship. Can someone help me out in fixing this problem?
Below is my code to find the number of prime numbers
def prime_number(num):
myprime = []
for x in range(2,num):
prime = True
if x == 2:
myprime.append(x)
else:
for y in prime:
if x%y == 0:
prime = False
break;
if prime:
myprime.append(x)
return myprime
This is my error:
TypeError Traceback (most recent call last)
<ipython-input-87-cd2bf40e6117> in <module>
----> 1 prime_number(100)
<ipython-input-86-169e0a64e50a> in prime_number(num)
13 else:
14
---> 15 for y in prime:
16
17 if x%y == 0:
TypeError: 'bool' object is not iterable
Can you also tell me how to fix the indentation or learn more about Indentation in python. I got to know identation in python is very important. I am using python 3 version.