#๐Ÿ”’ I am trying to make a wave like pattern can you help me in a step

38 messages ยท Page 1 of 1 (latest)

nocturne elbowBOT
#

@leaden jetty

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.

leaden jetty
#
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

versed spire
#

i will try to help

fluid plover
#

uhh what's the problem?

versed spire
#

i will try to make it

fluid plover
balmy ferry
nocturne elbowBOT
# balmy ferry !e - looks like this works ```py for n in range(10): print("โ—"*n) ``` what ar...

:white_check_mark: Your 3.13 eval job has completed with return code 0.

001 | 
002 | โ—
003 | โ—โ—
004 | โ—โ—โ—
005 | โ—โ—โ—โ—
006 | โ—โ—โ—โ—โ—
007 | โ—โ—โ—โ—โ—โ—
008 | โ—โ—โ—โ—โ—โ—โ—
009 | โ—โ—โ—โ—โ—โ—โ—โ—
010 | โ—โ—โ—โ—โ—โ—โ—โ—โ—
leaden jetty
balmy ferry
#

or did u want to animate it, to run on a single/multie lines?

leaden jetty
#

I don't know how to decrease

fluid plover
#

n=n-1 i think this might work

balmy ferry
# leaden jetty Yeah decrease after increasing to 10

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

nocturne elbowBOT
#

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`.
leaden jetty
#

I used reversed it's say reversed object<code>

balmy ferry
#

!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)
nocturne elbowBOT
# balmy ferry !e - working with this, using negative steps, inside `range()` โ€” ```py for n in...

: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

leaden jetty
#

Oo we can use reversed with range

#

New topic for me thanks

#

Now I can do it

balmy ferry
nocturne elbowBOT
balmy ferry
#

meaning that the first part/print would be printing nothing(/empty string)

#

!e

print("โ—"*0)
print("โ—"*1)
nocturne elbowBOT
balmy ferry
#

consider starting the sequence from 1; range(1, 10) .

balmy ferry
#

@leaden jetty (didn't ping ;-;)

nocturne elbowBOT
#
Python help channel closed for inactivity

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.