#๐ Help please
23 messages ยท Page 1 of 1 (latest)
@restive turtle
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
output I get sorry forgot to include
well, you'd need to print some spaces before you print any digits.
I don't get that output, at all
(echo 5; echo 0) | uv run python nikto.py
Enter Number for Rows or 0 to quit: 111
111
1111
11111
Enter Number for Rows or 0 to quit:
you probably didn't paste exactly the same code that you're running
print(' ' * number_of_spaces)
exactly that two seconds
that will print some spaces, followed by a newline. Probably not what OP wants.
https://paste.pythondiscord.com/GWNQ
@frigid hill @old needle here my bad
hm.. then couldn't you just add a comma in the print statement and add their number to it
print(' ' * number_of_spaces, number)
try it and see
I can just paste what works for me, but I probably can't explain in detail how I did it -- I just poked at it instinctively until I got something working
Ill try to pick at your brain based off what you wrote. May I see
sure
def print_pyramid(rows: int) -> None:
for i in range(1, rows + 1):
print(" " * (rows - i), end="")
for j in range(i, 0, -1):
print(j, end="")
for j in range(2, i + 1):
print(j, end="")
print()
def main() -> None:
while True:
num_rows = int(input("Enter number for Rows or 0 to quit: "))
if num_rows == 0:
break
print_pyramid(num_rows)
main()
(echo 5; echo 0) | uv run python nikto.py
Enter number for Rows or 0 to quit: 1
212
32123
4321234
543212345
๐ btw for using type hints
my guy @old needle I do understand I feel stupid for the lil extra i added. But in all thank you my guy ๐
Will see you soon you've helped me a lot lol so thank you sir
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.