#πŸ”’ Random purple 'def'

29 messages Β· Page 1 of 1 (latest)

slender sail
#

Why is this def function purple out of all the normal blue def. It's bugging me out so much. Is there any fix?

obtuse plumeBOT
#

@slender sail

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.

turbid light
slender sail
#

OH YEAH I NOTICED

#

Yeah, thanks, I noticed

#

I thought it's some IDE issue, it was my code

#

Thanks!

turbid light
#

also the outer () is optional in python, so if index < len(frontier) also suffices

slender sail
#

So it kinda moved over to Python

untold valley
#

Another common trap is trying to do C-style loops in Python so look out for that.

slender sail
#

What is C-style loop?

untold valley
#
for (int i = 0; i < 5; ++i) {

slender sail
#

Oh definitely not

#

The IDE will scream like crazy when it sees that

#

πŸ˜‚

turbid light
#

looping with indices instead of looping directly with values
e.g.

for i in range(len(stuff)):  # C style
    value = stuff[i]
    ...

for value in stuff:  # Pythonic
    ...

for i, value in enumerate(stuff):  # if you also need the index
    ...
slender sail
#

Thanks for the warning

untold valley
#

Yeah don't mention it.

#

Purplys explanation is better.

slender sail
#

Roger that

#

Thanks both

#

How do I close the thread

turbid light
#

!close, or just leave it as it'll automatically close after 1 hr of activity
and if anyone has more stuff to add they can

slender sail
#

Thanks, I think you guys helped me more than enough already

#

!close

obtuse plumeBOT
#
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.