#π Need help
29 messages Β· Page 1 of 1 (latest)
@half sonnet
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.
I don't think the start is what you think it is, can you show what the question ask?
real shi wrong code mb π here. Been trying anything past hour
https://paste.pythondiscord.com/6FLQ
but this code still dont work ofc
dont wanna ping you lol but here
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
you can define a number like value = 0 and each you you print the value % 10, you increment value by 1
this is before new paste btw
but your new paste still have the same issue
^^
so im changing codes at line 4 and 5 is that on right track or wrong?
no, you fix the print on line 6
Boom used {size}
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)```
Hey @half sonnet!
Add a py after the three backticks.
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
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()```
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?
Hey @half sonnet!
Add a py after the three backticks.
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
it made all zero but im sure its me messinmgh upo
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 π
!close when you done to close the post
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.