wow it's me again!

i have:

while i<11:
        print i,
        print ''

this gives the answer:

i need to give the answer.

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

i know my code has print i which is only temporary and it should be print *.
Is there any command that can do someting like:

For amount in i:
print '*'

specifically whatever integer is in i to print that many '*'s

i know of

for i in range(10)

but i must keep this in while and cant use for.

i understand this is long and i appreciate your patience thanks.

replace print i with print "*" * i . You may need to initialize i to 1 instead of 0.


Actually, that's the easy way out. The other way which might be the one your tutor is looking for (since this seems like homework) is to create another loop inside that loops i times, printing "*" on each iteration. Hint: use print "*", instead of print "*" to get the next "*" you print to stay on the same line.

smart help

ahh yes that seems so simple i've done times i and such before i dont know why i didint think of it.

Yeah that could be the easy way out. But i have to admit that is what i would have done (since that was where i was heading weith my code)

Haha yur just a guessing machine, yes it is homework from tutor =)

and the for loop i am changing from does have a 2nd loop that loops '*'s. So i probably should do as you said and do a 2nd loop.

the for loop i am converting from does use a '*', but i just assumed the , was just instead of ;

guess not.

thanks i'll give the harder one a go, haha and your always helping me, your like my pocket helper. and i thank you for it ^^

This article has been dead for over six months. Start a new discussion instead.