#๐Ÿ”’ I have a problem where everything is random

18 messages ยท Page 1 of 1 (latest)

spring rockBOT
#

@broken timber

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.

broken timber
#

here is the code

snow mason
broken timber
#

yes

snow mason
#

what you can do is check if x in range(3), remembering that the 3 won't be included due to how range works

broken timber
#

ยดso i just need to rearange it

#

x in range(0,1,2) like this

snow mason
broken timber
#

ah

snow mason
#

!d range

spring rockBOT
#

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`.
broken timber
#

i did it

snow mason
#

example
range(4) -> [0, 1, 2, 3]
range(1, 4) -> [1, 2, 3]
range(0, 4, 2) -> [0, 2]

broken timber
#

ty so much

#

its still random somehow

spring rockBOT
#
Python help channel closed

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.

#

๐Ÿ”’ I have a problem where everything is random