![]() |
Pyramid of leters of n levels - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: Pyramid of leters of n levels (/thread-21370.html) |
Pyramid of leters of n levels - DanyMont1505 - Sep-26-2019 PirĂ¡mide de Letras de n niveles Iam asked to write a program in python that uses the for function to print a pyramid of leters of n levels. To obtain the levels of the pyramid the code must ask for a number between 1 and 26. Example: The code must return the following pyramid when the input is 3: A A B A A B C B A Can you help to figure out how to do this, im learning python and so far the teacher hasn't showed us how to do something like this RE: Pyramid of leters of n levels - metulburr - Sep-26-2019 Moved to homework forum for obvious reasons. I could not imagine that an instructor would give a question to something they have not instructed on how to do. Aside from that, what have you tried so far? RE: Pyramid of leters of n levels - DanyMont1505 - Sep-26-2019 Well, I haven't tried coding it yet but i've been thinking about making making a for statement that then compares de i so it can enter trough multiple if cases and then print them. Something like control = int(input()) for i in range (1, control+1): if i == 1: print(' A ') if i == 2: print(' A B A ')and so on RE: Pyramid of leters of n levels - jefsummers - Sep-26-2019 Couple things - your coding would center the pyramid, while your example of the desired output is left justified. Both possible, latter easier, which is it? And, have you been taught/can you use lists? Finally, your code would print the pyramid upside down, printing the A first, then the ABA, etc. RE: Pyramid of leters of n levels - woooee - Sep-27-2019 You print a certain number of spaces and then the letter(s). The next line prints fewer spaces and more letters. Rinse and repeat. |