#π basic problem
114 messages Β· Page 1 of 1 (latest)
@muted grail
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.
my current code gives me a staircase
not a pyramid

I've also attatched the task requirement that needs to be fullfilled
you probably need to center your stars
yea but how
have you used f-strings yet?
nope we havent been taught that yet
are you allowed to use it?
okay then you need to manually calculate the number of spaces to insert
hm
it should be very simple
actually it wouldn't be the number of #'s on each row, it'd be the number of # from the center to the left
so it'd just increase by 1 each time
1, 2, 3, ...
uh
in other words, i
maybe i+1 but you get the idea yeah?
there's also str.center but I assume you're not allowed to use that either
# Task 10: Output a pyramid of size defined by input of the symbol defined through input
size=int(input("Enter size:"))
symbol=input("Enter symbol:")
for i in range(1,size+1):
print(""*i,2*symbol*i)
progress 
this might sound stupid
but
/ gives us a float value and // gives us an ineteger
right
uhh in this case yes
// is floor division, if you use it on two integers it will return an integer
otherwise it will return a float that has been floored (rounded towards -infinity)
whats wrong with my print statement
print(" "*(size//2)-1,2*symbol*i)
2 things, your space calculation doesn't change as you loop (you are not using i in it), and your second part isn't using string multiplication to produce the #'s
size=int(input("Enter size:"))
symbol=input("Enter symbol:")
for i in range(1,size+1):
print(" "*(size//2)-i,2*symbol*i)
oh that's because of operator precedence
* happens before - so you have to do the math in one big parenthesis
(size//2-i)
// has higher precedence than - so you don't need to wrap parens around the division
bodmas 
size=int(input("Enter size:"))
symbol=input("Enter symbol:")
for i in range(1,size+1):
print(" "*(size//2-i),2*symbol*i)
im getting closer.
oh size here is the height of your triangle isn't it?
yep
pyramid
not triangle
our goal is to make a pyramid
well triangle
same thing
LMAO
with that formula is should be the width of the last row
its 2d woopsie
you just gotta fix your symbol calculation
mhm
right now it's 2*i which gives you 2, 4, 6, ...
so how could you change 2*i to give you 1, 3, 5, ...
mhm
parens again
i think its the same issue
operator precedence
yeah
so i put the paranthesis around
print(" "*(size-i),(2*symbol*i)-1)
like this?
uhh
no
all your math involving numbers should be in the parens
then multiply that with symbol
yh
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, 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.