Nested for loops

I am trying to work through some old C++ assignments in Python to try and get a handle on it.  One of these assignments had to do with nested for loops.  What it did was print the pattern below:

*                    **********    **********                    *    
**                  *********        *********                  **
***                ********            ********                ***
****              *******                *******              ****
*****            ******                    ******            *****
******          *****                        *****          ******
*******        ****                            ****        *******
********      ***                                ***      ********
*********    **                                    **    *********
**********  *                                        *  **********

I did it with the following C++ code:

#include <iostream>
using namespace std;

int main ()
  int i, j;

//Loop through the other loops
  for (i= 1; i< 11; i++) {
      //print * and spaces for first block
    for (j= 0; j< i; j++) cout << '*';
    for (j= 0; j< 11- i; j++) cout << ' ';

      //print * and spaces for second block
    for (j= 0; j< 11- i; j++) cout << '*';
    for (j= 0; j< i; j++) cout << ' ';

      //print * and spaces for third block
    for (j= 0; j< i; j++) cout << ' ';
    for (j= 0; j< 11- i; j++) cout << '*';

      //print * and spaces for fourth block
    for (j= 0; j< 11- i; j++) cout << ' ';
    for (j= 0; j< i; j++) cout << '*';

    cout << '\n';
     cout << "Hit enter:";
     return 0;

I guess I am not thinking very pythonically here, but I cant seem to get it done.  I end up with a version that prints to thhe left column of the screen but throws a crlf in there and then prints the next block below.  Here is a partial code snippet:

for i in range (1,11):
      for j in range (0,i):
            print "*"*i
      for j in range (0,11):
            print " "*j
      for j in range (0,11-i):
            print "*"*i
      for j in range (0,i):
            print " "*j

Any input would be greatly appreciated.  My frustration meter is pegged and I can't believe I can't figure this one out for myself.

The embarrassed python newbie
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ramromconsultant Commented:
Put a comma at the end of all but the last print to suppress the newline that print supplies.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bnblazerAuthor Commented:
Your ',' suggestion led me on the right path.  Thank you.  The code to make the above pattern is:

for i in range (1,11):
      print "*"*i + " "*(11-i) + "*"*(11-i) + " "*i + " "*i + "*"*(11-i) + " "*(11-i) + "*"*i
Gertone (Geert Bormans)Information ArchitectCommented:
Hi bnblazer,

I bet this comes closer

for i in range (1,11):
     for j in range (0,i):
          print "*",
     for j in range (0,11 - i):
          print "  ",
     for j in range (0,11-i):
          print "*",
     for j in range (0,i):
          print " ",
     print ''

as ramrom said, you need a comma
but on all statements
right before the end of the outer for you need a print '' without a comma, for the newline
and there is no need to do print "*"*j,
print "*" is enough, since you have the inner for

Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

Gertone (Geert Bormans)Information ArchitectCommented:

ignore my post
did not see you already concluded


ramromconsultant Commented:
Your code has other problems. Example:  "*"*i gives you a string of i asterisks. Doing that in a for loop gives you many more asterisks than you want.
Either drop the *i or the for.

Most pleasing to my eye would be:

for i in range(1,11): print "*"*i + " "*(11-i) + "*"*(11-i) + "  "*i + "*"*(11-i) + " "*(11-i) + "*"*i
ramromconsultant Commented:
Oh well I started my answer a while back, then went to meditate. Now I see you have come to the same conclusion.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.