#๐Ÿ”’ Help right quick

21 messages ยท Page 1 of 1 (latest)

short thorn
pure boneBOT
#

@short thorn

Python help channel opened

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.

neat lodge
#

you mean the color?

short thorn
#

No referring to the formatting of the diamond shape compare to my output

grave drift
#

!e

# Function to create diamond
def diamond(size):
# Make sure size is odd
    if size % 2 == 0:
        size += 1
        print(f"Size must be an odd number; we will increase it to 9")
# FOR loop for the top half of diamond
    for i in range(size // 2 + 1):
        for j in range(size // 2 - i):
            print("", end="")
# Print the increase number from 0 to 9
        for j in range(2 * i + 1):
            print(j % 10, end="")
        print()
# FOR loop the bottom half
    for i in range(size // 2 - 1, -1, -1):

        for j in range(size // 2 - i):
            print("", end="")
# Print increasing numbers 0 to 9 on bottom half
        for j in range(2 * i + 1):
            print(j % 10, end="")
        print()
# define the main function and get input to generate the diamond
def main():
    size = 3
    diamond(size)

main()
pure boneBOT
grave drift
#

I don't see you adding any spaces to the left side

spring basin
#

print("", end="") is pointless

#

where's the space

short thorn
#

@grave drift @spring basin

def diamond(size):
# Make sure size is odd
    if size % 2 == 0:
        size += 1
        print(f"Size must be an odd number; we will increase it to 9")
# FOR loop for the top half of diamond
    for i in range(size // 2 + 1):
        for j in range(size // 2 - i):
            print("", end=" ")
# Print the increase number from 0 to 9
        for j in range(2 * i + 1):
            print(j % 10, end="")
        print()
# FOR loop the bottom half
    for i in range(size // 2 - 1, -1, -1):

        for j in range(size // 2 - i):
            print("", end=" ")
# Print increasing numbers 0 to 9 on bottom half
        for j in range(2 * i + 1):
            print(j % 10, end="")
        print()
# define the main function and get input to generate the diamond
def main():
    size = int(input("Enter an odd number for the size of the diamond: "))
    diamond(size)

main()``` 
Added the spaces, I also dont know why my numbers isn't exactly in order anything you spot?
pure boneBOT
#

Hey @short thorn!

Please edit your message to use a code block

Add a py after the three backticks.

```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
grave drift
#

!e

# Function to create diamond
def diamond(size):
# Make sure size is odd
    if size % 2 == 0:
        size += 1
        print(f"Size must be an odd number; we will increase it to 9")
# FOR loop for the top half of diamond
    for i in range(size // 2 + 1):
        for j in range(size // 2 - i):
            print("", end=" ")
# Print the increase number from 0 to 9
        for j in range(2 * i + 1):
            print(j % 10, end="")
        print()
# FOR loop the bottom half
    for i in range(size // 2 - 1, -1, -1):

        for j in range(size // 2 - i):
            print("", end=" ")
# Print increasing numbers 0 to 9 on bottom half
        for j in range(2 * i + 1):
            print(j % 10, end="")
        print()
# define the main function and get input to generate the diamond
def main():
    size = 5
    diamond(size)

main()
pure boneBOT
grave drift
grave drift
#

all these range calls you're using are generating 0 through stop-1

#

you could have a counter variable and just increment it in every loop and use that as the number you write out, or do the math for your range calls to properly generate the numbers you need

grave drift
pure boneBOT
#
Python help channel closed for inactivity

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.