On 2020-04-05 05:22:45 -0700, Sathvik Babu Veligatla wrote:
> I am new to python, and i am trying to output the prime numbers
> beginning from 3 and i cannot get the required output. It stops after
> giving the output "7" and that's it.

A technique I learned when I started programming (back in the days when
computers were made from bones and rocks), is to "play computer":

Grab a piece of paper and a pencil. Make a column for each variable (a,
l, and i in your case). Then walk through the code line by line, think
about what each line does, and every time a new value is assigned to a
variable, note the new value on your paper.

Do the values of the variables change the way you expect them to? If
not, why not?

        hp

PS: You can also single-step through the program in a debugger, but I
think doing this by hand on a piece of paper is very useful, especially
for a beginner, since it forces you to think what happens (The downside
is of course that you may make mistakes - but then you can learn from
them).

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | h...@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Attachment: signature.asc
Description: PGP signature

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to