In python how do I get sice(0, 5).end?
In python how do I get sice(0, 5).end?
The Python `slice` object (note the spelling) has attributes called `start`, `stop`, and `step`, not `end`. To get what you're looking for:
1 2 | my_slice = slice(0, 5) print(my_slice.stop) # This will output 5 |
Testing if the previous output contains the string .stop
: True
In python how do I get sice(0, 5).end?
In python how do I get sice(0, 5).end?
It looks like there might be a small mistake in your question. The `slice` object in Python doesn't have an `.end` attribute - it has a `.stop` attribute instead. Here's how to get the end value of a slice:
1 2 3 4 | my_slice = slice(0, 5) end_value = my_slice.stop print(end_value) # Outputs: 5 |
Testing if the previous output contains the string .stop
: True