#๐Ÿ”’ helo

30 messages ยท Page 1 of 1 (latest)

outer lanternBOT
#

@old rain

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.

floral quail
#

!code

outer lanternBOT
#
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.

floral quail
#
    if text == "hello" or "hello, there" or "hello, newman":

that does not what you think it does

old rain
#

wdym

#

should i add different elif statement

#

on this?

#

without "or"

floral quail
#

== and or are logical junctors they connect logical expression so on both sides stands a independend expression

old rain
#

what should i use then

floral quail
#

!or

outer lanternBOT
#
The or-gotcha

When checking if something is equal to one thing or another, you might think that this is possible:

# Incorrect...
if favorite_fruit == 'grapefruit' or 'lemon':
    print("That's a weird favorite fruit to have.")

While this makes sense in English, it may not behave the way you would expect. In Python, you should have complete instructions on both sides of the logical operator.

So, if you want to check if something is equal to one thing or another, there are two common ways:

# Like this...
if favorite_fruit == 'grapefruit' or favorite_fruit == 'lemon':
    print("That's a weird favorite fruit to have.")

# ...or like this.
if favorite_fruit in ('grapefruit', 'lemon'):
    print("That's a weird favorite fruit to have.")
old rain
#

a

#

AttributeError: 'str' object has no attribute 'startswiths'. Did you mean: 'startswith'?

#

why startswith

#

won't works

#

i asked gpt but

#

none help

#

0%

#

this seems can't read this str method

floral quail
#

!code

outer lanternBOT
#
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.

floral quail
#

post your code formatted

old rain
#

nvm

#

done

#

i just make it only main func

#

and startwith worked

outer lanternBOT
#
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.

#

๐Ÿ”’ helo