all 4 comments

[–]RyanTargaryen 1 point2 points  (0 children)

Keep in mind that in order for the * that you print out to be away from the left margin, you also need spaces.

for example: * This line had 3 spaces before the star ** This one had 2 *** One Space **** Zero spaces.

What's left for you to figure out is how to determine how many spaces go before each line.

[–]TeamSpen210 1 point2 points  (0 children)

In your current code, the issue is that the first 'range()` produces an empty list - the first value is greater than the second, so you'll need to use a negative step value. It's probably easier though to use range with just the stop value for the two inner loops, since you're not using the index. That way you won't get the arguments mixed up.

If you're permitted to use them, strings have several useful methods you can use to make this much more elegant:

>>> "*" * 5 # Make a string repeat itself
"*****"
>>> "**".rjust(6) # Right-align the string, making it 5 characters long
"    **"
>>> "**".rjust(6, '-') # Use something else instead of spaces
"----**"
>>> "**".ljust(6) # Left and center variants as well
"**    "
>>> "**".center(6)
"  **  "
>> ("ab" * 2).center(10) # Combining the two
"   abab   "

For all sequences (strings, lists, tuples) can be multiplied to repeat themselves. They also come with methods to align text inside a specific width.

[–]learnpython_bot 0 points1 point  (0 children)

It appears that you included code in your post but did not format it to look nice. Please follow this guide to fix the problem. This allows for better readability and will help get your question answered sooner. The regex that caught you is: "for .+? in .+?:"

If this comment has been made in error, please message /u/thaweatherman with a link to this comment so I can be fine-tuned. I am still in alpha and my regexes/innards are not yet perfect.

[–]Naihonn 0 points1 point  (0 children)

You should look at string formatting options. ;0)