Jan-28-2022, 03:36 PM
I agree with you. My goal was to print the result with and without a list.
At first i wanted to print without a list but ended up with False and True. Removing false or true get you a none.
Than i returned n to only get the primes. But true is in output. I tried for fun Ruby language. I like the idea to not have to return something (return is automatic). In python you have to return otherwise nothing comes out.
In the end your solution is what i was looking for. Just that was enough:
At first i wanted to print without a list but ended up with False and True. Removing false or true get you a none.
Than i returned n to only get the primes. But true is in output. I tried for fun Ruby language. I like the idea to not have to return something (return is automatic). In python you have to return otherwise nothing comes out.
In the end your solution is what i was looking for. Just that was enough:
for n in range(1,21): if is_prime_v1(n): print(n) print(prime)Again a logic problem i suppose.