#๐ I am trying to make a wave like pattern can you help me in a step
38 messages ยท Page 1 of 1 (latest)
@leaden jetty
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.
import time
def design():
while True:
for x in range(10):
print("*"*x)
time.sleep(0.2)
design()
I want that after stars increase to 10 they should decrease and then increase so a wave like pattern form
@versed spire
uhh what's the problem?
This I want to do this
soo it'll just start with 10 and dicrease one by one ?
Uh?
!e - looks like this works
for n in range(10):
print("โ"*n)
what are you having trouble with? maybe having it decrease in length?
:white_check_mark: Your 3.13 eval job has completed with return code 0.
001 |
002 | โ
003 | โโ
004 | โโโ
005 | โโโโ
006 | โโโโโ
007 | โโโโโโ
008 | โโโโโโโ
009 | โโโโโโโโ
010 | โโโโโโโโโ
Yeah decrease after increasing to 10
or did u want to animate it, to run on a single/multie lines?
This
I don't know how to decrease
n=n-1 i think this might work
well you could go about it in multiple ways.
some quick examples -
โข using another loop, with negative steps.
โข using reversed()
โข creating a cycle; using a while loop, or the builtin itertools.cycle().
!d range
class range(stop)``````py
class range(start, stop[, step])```
The arguments to the range constructor must be integers (either built-in [`int`](https://docs.python.org/3/library/functions.html#int) or any object that implements the [`__index__()`](https://docs.python.org/3/reference/datamodel.html#object.__index__) special method). If the *step* argument is omitted, it defaults to `1`. If the *start* argument is omitted, it defaults to `0`. If *step* is zero, [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError) is raised.
For a positive *step*, the contents of a range `r` are determined by the formula `r[i] = start + step*i` where `i >= 0` and `r[i] < stop`.
For a negative *step*, the contents of the range are still determined by the formula `r[i] = start + step*i`, but the constraints are `i >= 0` and `r[i] > stop`.
I used reversed it's say reversed object<code>
!e - working with this,
using negative steps, inside range() โ
for n in range(10, -1, -1):
print("โ"*n)
using reversed()
print("\nUsing reversed โ\n")
for n in reversed( range(10) ):
print("โ"*n)
:white_check_mark: Your 3.13 eval job has completed with return code 0.
001 | โโโโโโโโโโ
002 | โโโโโโโโโ
003 | โโโโโโโโ
004 | โโโโโโโ
005 | โโโโโโ
006 | โโโโโ
007 | โโโโ
008 | โโโ
009 | โโ
010 | โ
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/5SQG63MD7MSRYFCF7755NRA5D4
!e - do notice that simply stating range(10), yields a sequence that starts from zero(0)
print( list(range(10)) )
:white_check_mark: Your 3.13 eval job has completed with return code 0.
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
meaning that the first part/print would be printing nothing(/empty string)
!e
print("โ"*0)
print("โ"*1)
:white_check_mark: Your 3.13 eval job has completed with return code 0.
001 |
002 | โ
consider starting the sequence from 1; range(1, 10) .
^ for more info, regarding range() functionality, refer to this.
@leaden jetty (didn't ping ;-;)
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.