#๐Ÿ”’ Gang can someone explain me the reason behind

35 messages ยท Page 1 of 1 (latest)

spare ravine
#

if i == len(arr) - 1:
return

fleet belfryBOT
#

@spare ravine

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.

spare ravine
#

I mean what's the purpose of -1 , here

lusty karma
#

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

spare ravine
#

so in the output it'll show 4 elements

astral crescent
#

No the output is a boolean

spare ravine
#

nah I'm just telling in basic case

random stone
spare ravine
#

@astral crescent

astral crescent
#

!code

fleet belfryBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

spare ravine
#

!code

astral crescent
#

Read the message bro

astral crescent
random stone
astral crescent
#

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

spare ravine
#

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

spare ravine
#

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

fleet belfryBOT
#
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.