On Sun, Oct 19, 2014 at 7:32 AM, jarod...@libero.it <jarod...@libero.it> wrote: > > Dear All, > or improve my understanding o python I would like to learn how to draw simple > figures using loops. > I start from this code in java: > import java.util.Scanner; > > public class Eserc2_8 { > public static void main(String args[]) { > Scanner s = new Scanner(System.in); > // Altezza del triangolo > int altezza = s.nextInt(); > > for (int riga = 1; riga <= altezza; riga++) { > int i = 0; > while (i<altezza-riga) { > System.out.print(" "); > i += 1; > } > i = 0; > while (i< (riga*2)-1) { > System.out.print("*"); > i += 1; > } > System.out.println(""); > } > } > } > > and I want to transfer to python loops: > > for i in range(10): > #space > for t in range(6-i): > print "" > for item in range(i+1): > print "." > > > But I ha not succed. So someone could you please explain how can work' > thanks a lot > bw > what is your output? What errors (print complete traceback)
You probably want print " ", and print ".", so that there is no added newline. > > > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor -- Joel Goldstick http://joelgoldstick.com _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor