[Tutor] (no subject)

Alan Gauld alan.gauld at btinternet.com
Tue Mar 24 00:28:15 CET 2009


"Jared White" <dukelx2005 at gmail.com> wrote 

>    Help If u can please i got this code to work for the top half

You were already given a couple of hints on how to maker 
this easier but you seem to have ignored both of them

Look again at using a for loop and the range() function.
Then look at printing a string using the multiplication operator
ie.
print '*' * 5

These things will greatly simplify your program
If you then look at the range function again you should 
see how to implement the bottom half of your pattern.

Try using these hints and copme back for more help if it 
doesn't work.

> def main():
>    i=1
>    while i <=10:
>        j=1
>        while j<=i:
>            print  '*',
>            j=j+1
>        print
>        i=i+1
> main()


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list