#πŸ”’ Need help

29 messages Β· Page 1 of 1 (latest)

neon quartzBOT
#

@half sonnet

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.

zealous prawn
#

I don't think the start is what you think it is, can you show what the question ask?

half sonnet
#

but this code still dont work ofc

#

dont wanna ping you lol but here

zealous prawn
#
if size % 2 == 0: # Line 4
β”‚  β”‚      β”‚ β”‚  ╰──is 0
β”‚  β”‚      β”‚ ╰──True
β”‚  β”‚      ╰──Result: 0
β”‚  ╰──if this is odd and not 8 (x)
╰──True -> execute
size += 1
β”‚       ╰──x -> x : x % 2 == 1, x != 9
╰──x: x % 2 == 0, x != 8
print(f"Size must be an odd number; we will increase it to 9")
                                                           ╰──You didn't increase to 9 if input != 8 and is odd

small problem

zealous prawn
zealous prawn
#

but your new paste still have the same issue

half sonnet
#

^^

half sonnet
zealous prawn
#

no, you fix the print on line 6

half sonnet
#

on line 6 and now I convert it to odd number

#

the number pattern im still messing on anything you see there that I need to change?'

#
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 {size}")
# 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 odd number
        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 from 0 to odd number 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)```
neon quartzBOT
#

Hey @half sonnet!

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!')```
half sonnet
# zealous prawn here

i messed up it gives output of all zeros

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 {size}")
# 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 odd number
        for j in range(2 * i + 1):
            value = 0
            print(value % 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 from 0 to odd number on bottom half
        for j in range(2 * i + 1):
            value = 0
            print(value % 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()```
zealous prawn
#

you keep setting value = 0, I said only at the start of the function

half sonnet
# zealous prawn you keep setting value = 0, I said only at the start of the function

Sorry pal dont mean to be stupid im sure its frustrating 😭

def diamond(size):
    value = 0
# Make sure size is odd
    if size % 2 == 0:
        size += 1
        print(f"Size must be an odd number; we will increase it to {size}")
# 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 odd number
        for j in range(2 * i + 1):

            print(value % 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 from 0 to odd number on bottom half
        for j in range(2 * i + 1):
            print(value % 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()``` start of function yes?
neon quartzBOT
#

Hey @half sonnet!

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!')```
half sonnet
#

it made all zero but im sure its me messinmgh upo

zealous prawn
#

each you(*time) you print the value % 10, you increment value by 1

half sonnet
# zealous prawn > each you(*time) you print the value % 10, you increment value by 1

._. that one got into my head

def diamond(size):
    value = 0
# Make sure size is odd
    if size % 2 == 0:
        size += 1
        print(f"Size must be an odd number; we will increase it to {size}")
# 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 odd number
        for j in range(2 * i + 1):
            print(value % 10, end="")
            value += 1
        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 from 0 to odd number on bottom half
        for j in range(2 * i + 1):
            print(value % 10, end="")
            value += 1
        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()``` now code works. you the man thank you! continue doing god blessing we deeply appreciate you πŸ™
zealous prawn
#

!close when you done to close the post

neon quartzBOT
#
Python help channel closed using Discord native close action

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.