-3

I do not know how to use loops in python and need help to make this pattern:

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

This is what I have tried:

for x in range(0, 5):
  print ("*")    

And the result is:

*
*
*
*
*
3
  • This pattern is not the one I am looking for. Commented Sep 26, 2015 at 2:15
  • there are several questions about just this topic, including stackoverflow.com/questions/22287100/… - so just modify the answer found there Commented Sep 26, 2015 at 2:16
  • Please, my assingment is due soon, i am a beginner in programming Commented Sep 26, 2015 at 2:18

1 Answer 1

0

Here's a step-by-step solution.

# for loop
for cnt in range(1,6):
    # print 'cnt' number of asterisks
    print(cnt * '*')

The result is:

*
**
***
****
*****
Sign up to request clarification or add additional context in comments.

1 Comment

Or use the counter you already have... for num in range(1,6): print('*' * num)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.