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

  • SEARCH
  • Home
  • 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 8069505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:04:23+00:00 2026-06-05T13:04:23+00:00

I’m creating a list of files with coordinates and id numbers. a is just

  • 0

I’m creating a list of files with coordinates and id numbers.
a is just an arbitrary value to space out points. f is a file opened earlier and closed later.
I’m using the code listed below. It should generate 511 points, skipping one point that would’ve originally been the 293rd point. Instead it is skipping 169 points and I cannot figure out why. Any help on this would be greatly appreciated.

id=1

for i in range(0,8,1):
    for j in range(0,8,1):
        for k in range(0,8,1):
            x1=i*a
            y1=j*a
            z1=k*a
            if ((i!=4) & (j!=4) & (k!=4)):
                f.write("%4.d  1  4  %4.3f  %4.3f  %4.3f\n"%(id, x1, y1, z1))
                id=id+1
  • 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-05T13:04:25+00:00Added an answer on June 5, 2026 at 1:04 pm

    Since you require that i must be different from 4 AND j must be different from 4 AND k must be different from 4, you are skipping all points where ANY of these is 4. Use

    if i != 4 or j != 4 or k != 4:
    

    instead. Equivalently, but probably easier to grasp, you could write

    if not (i == 4 and j == 4 and k == 4):
    

    or even better

    if i, j, k != 4, 4, 4:
    

    Edit: Here’s a completely rewritten version of your code:

    points = itertools.product(range(0, 8 * a, a), repeat=3)
    points = (p for p in points if p != (4 * a, 4 * a, 4 * a))
    with open("filename", "w") as f:
        for id_p in enumerate(points, 1):
            f.write("%4.d  1  4  %4.3f  %4.3f  %4.3f\n" % id_p)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have an array which has BIG numbers and small numbers in it. I
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I know there's a lot of other questions out there that deal with this

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.