Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9166237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:06:34+00:00 2026-06-17T15:06:34+00:00

I am doing a simple script for self learning in python where the scripts

  • 0

I am doing a simple script for self learning in python where the scripts in turn finds the 1000th prime number but I get a syntax error.

x = 0
y = 2
counter = x
integer = y
while (counter>999):
      if (y%2 == 0 or y%3 == 0):
          y = y + 1
      else:(counter = counter + 1 and integer = integer + 1)
print (y)    

when it comes to the =’s assignment right after the ELSE operator and I don’t understand why it won’t let me add one to both the counter and integer when this has worked in other iteration scenario

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T15:06:35+00:00Added an answer on June 17, 2026 at 3:06 pm

    In python you can’t make an assignment inside an expresion, to avoid misspellings between = and ==. So you must do that in two lines:

    x = 0
    y = 2
    counter = x
    integer = y
    while (counter>999):
        if (y%2 == 0 or y%3 == 0):
            y = y + 1
        else:
            counter += 1
            integer += 1
    print (y)    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Doing some javascript self-learning and the program itself is very simple. It searches through
Doing a simple Squeryl database lookup, but trying to exclude a value. I've tried:
I am doing a simple JSP program to connect with MySQL DB. But it's
I am doing some self-learning about JQuery. Here is the code for my very
I'm writing a really simple lexer for doing syntax highlighting of arbitrary text, one
First time doing Python in a while, and I'm having trouble doing a simple
I'm doing a simple chat script and I have the killSession function which kills
It's very convenient to have R scripts for doing simple plots from the command
I coded a relatively simple script using python and also wrote doc strings for
I'm doing a simple script to check crc of all files... require zlib exit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.