#๐ Gang can someone explain me the reason behind
35 messages ยท Page 1 of 1 (latest)
@spare ravine
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.
I mean what's the purpose of -1 , here
the important thing to remember is, that indices of lists start from 0
that means if you have a list of length 5, say like this:
['apple', 'orange','lemon', 'lime', 'blueberry']
then the respective indices are 0, 1, 2, 3, 4
so when i == len(my_list)-1 == 4, that's the last element
so in the output it'll show 4 elements
No the output is a boolean
nah I'm just telling in basic case
it is to detect if it is at the last element, because you would go out of bound if you do i + 1 at that point
@astral crescent
You need to actually say the code
!code
!code
Read the message bro
That isn't showing any elements, that's a number
mhm
len(l) - 1 give you the index of the last elemen
yeh
Notice that we do arr[i + 1]
In order for this to work, we have to stop i one before the last index
otherwise i + 1 is too large
sorry guys but I can't understand shit atp the i+1 stuff
okay lemme try to tell you guys what I've understand now that len(arr)-1 , will gonna print boolean according to the respective indices as @lusty karma said
here
now that case I understood ,
GANG
IG i understood
now
in 2nd case if arr[i] > arr[i+1]: , it'll gonna add false , as its in arr2 case . 5>8 (false)
tyy guys for the help I appericiate that
!lock
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.