I am new at Python can someone help me? (for loop and functions)

Guys, I am new at Python and ı am learning it myself. I am started to this: Prime numbers to 1 to “n”. n is input. Can you tell me where is the my fault.

I am using PyCharm.

Thanks :slight_smile:

Your problem is that liste is declared globally. This means that after checking 2 it will contain this: [1, 2]. Then when 3 gets checked it’ll look like this after the modulo loop completes: [1, 2, 1, 3], which makes the check fail.

Declare liste at the beginning of the asal_sayı function to solve the problem.

1 Like

Thank you so much :slight_smile:

1 Like