Print series of prime numbers in python

0 votes

I was having trouble printing a run of prime numbers between 1 and 100. I'm stumped as to why my code is broken.

Here is what I wrote; it displays all odd numbers rather than prime numbers.

for num in range(1, 101):
    for i in range(2, num):
        if num % i == 0:
            break
        else:
            print(num)
            break
Feb 17, 2023 in Python by Arya
• 990 points

edited 5 days ago 5 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP