The last function of code is printing out none instead of 0 and 1, pls what can I do to correct it?? Thanks. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

The last function of code is printing out none instead of 0 and 1, pls what can I do to correct it?? Thanks.

https://code.sololearn.com/cu4hEaJI5E58/?ref=app

10th May 2021, 4:45 AM
Adibeh Esther
Adibeh Esther - avatar
3 Answers
+ 1
That's because the return value of append() is "none"
10th May 2021, 4:51 AM
Arsenic
Arsenic - avatar
- 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)
10th May 2021, 4:48 AM
A͢J
A͢J - avatar
- 1
When I tried that, it's printing out what's in else. i.e. 0
10th May 2021, 6:08 PM
Adibeh Esther
Adibeh Esther - avatar