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 9310167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T01:02:53+00:00 2026-06-19T01:02:53+00:00

I have a 1D array e.g. arr1 = [1, 2, 3, 4, 5, 6,

  • 0

I have a 1D array e.g. arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, ...] of arbitrary length.

How do I print this to a text file (with integers/floats separated by spaces) so that every 7 elements are printed on the same line in the text file?

So I want the text file to look like this:

Line 1:1 2 3 4 5 6 7

Line 2:8 9 10 11 12 13 14

  • 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-19T01:02:54+00:00Added an answer on June 19, 2026 at 1:02 am

    you could do this:

    liNums = xrange(1, 20)
    x = 0
    line = ""
    for i in liNums:
        x+=1
        line += "%s " % i
        if not x%7:
            line += "\n"
    #send line to output, here I will just print it
    print line
    

    here every 7 items a new line is appended… output looks like this:

    1 2 3 4 5 6 7 
    8 9 10 11 12 13 14 
    15 16 17 18 19 
    

    hope that helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have the array, arr1. I want to print this array (i.e. just
I have an array like this: var arr1 = [a, b, c, d]; How
I have this array that searches for matches between two arrays. The problem is
I have an array something like this $arr1 = array( '0' => '674534856|213123213|232313123', '1'
I have this array, var arr1 = [19, 1, 1, 1, 1]; and another
I have array like this: $path = array ( [0] => site\projects\terrace_and_balcony\mexico.jpg [1] =>
I have array result like this: Array ( [0] => stdClass Object ( [id_global_info]
Suppose we have the Java code: Object arr = Array.newInstance(Array.class, 5); Would that run?
I have 2 or more dynamic string array that fill with some huge data
There's a String array that I have which has setter and getter methods. How

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.