+ 1
The last function of code is printing out none instead of 0 and 1, pls what can I do to correct it?? Thanks.
3 Respostas
+ 1
That's because the return value of append() is "none"
- 1
Adibeh Esther
Why you are appending here if you just want to print 1 an 0?
my_mer= []
for i in my_list:
if is_prime((mer_num(i))==True):
print(my_mer.append(1))
else:
print(my_mer.append(0))
-----------------------------
You can simply do this:
my_mer= []
for i in my_list:
if is_prime((mer_num(i))==True):
print(1)
else:
print(2)
- 1
When I tried that, it's printing out what's in else. i.e. 0