#๐ Help please!
35 messages ยท Page 1 of 1 (latest)
@wicked 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.
you could maybe check if t is divisible by 2 and base the spaces off of that
like
z
z
z
z
(idk if i understood what you want correctly)
I can see the issue but I would like to know whether you tried debugging using python breakpoint or just print statement?
Here you can learn on how to use breakpoint to debug python program in terminal: https://youtu.be/aZJnGOwzHtU?si=6rnG5ESextFnxHTE
Learn how to use the Python Debugger using the breakpoint() function in this Tutorial.
โ
Write cleaner code with Sourcery: https://sourcery.ai/?utm_source=youtube&utm_campaign=pythonengineer *
๐๐ SUPPORT ME ON PATREON ๐๐
https://www.patreon.com/patrickloeber
๐๐ JOIN MY NEWSLETTE...
uhhh sorry
bad explanation
need to look like this
i dont think its much use? its not that its an error its just how the answer is formatted
You do not debug only where there is an error, you use it to understand how your current program is behaving in real time.
Is it a homework or assignment you are trying to complete? Because it looks like so
oh mb
yessir
import time
def zigzag(char, distance, duration):
if not isinstance(char, str):
raise TypeError("char must be str")
if len(char) != 1:
raise ValueError("char must be of len 1")
if distance < 0:
raise ValueError("distance must be not negative")
elapsed = 0
i = 0
switch = False
while elapsed < duration:
start = time.perf_counter()
print(char.rjust(i + 1, " "))
i = i - 1 if switch else i + 1
if i == distance or i == 0:
switch = not switch
end = time.perf_counter()
elapsed += end - start
zigzag("B", 10, 1)
the hell bro
takes to long for the bot ๐
@warm knot it looks like an violation of rule no 8
@grave cypress do you see problem in my code?
take a look at the rjust() method of strings. it is possible to do it without it and implement it yourself but this method makes it easy because it is like a ready made solution
so you need only to loop throught the amout of spaces
and stop the time
and switch increasing and decreasing
bro when did python get so complicated
Yes there is a problem. First you have break your problem into separate parts. First would be to print "B" with increased spaces, such as:
B
B
B
B
Second, once you achieved this, then work on printing "B" in reversed order which will be opposite of the first step, like this:
B
B
B
B
Then last, combine first and second step and repeat it as many times you want
wasn
oops
wasn't the last couple of lines suppoused to do that though?
No, first your code inside your loop is not correct. This is why I asked to break your problem into multiple steps because that will help you.
python is not complicated it is extremly easy, you can not be more simple and easy than python. but that does not make creating a algorithm easier. think about an algorithm has nothing to do with the language. you could do it in pseudocode and implement it in any language
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.