Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new tag !in #211

Open
kortycodes opened this issue Apr 15, 2023 · 0 comments
Open

new tag !in #211

kortycodes opened this issue Apr 15, 2023 · 0 comments
Labels
area: tags Related to the @Python bot's tags type: addition Request to add something new

Comments

@kortycodes
Copy link

Heya.
I wrote a message for the bot for !in
I read through the !contribute bit but not too sure how to submit. If there’s a different way to do this, please let me know.

Feed back is of course welcome and highly appreciated.

I have another message regarding the use of a condition in if. Let me know if I can post that here as well or should do something else with it.

========= start of message ====
in
used to see if a is part of b.
a in b
return a boolean True/False.
Where b is an iterable.

Example

a = 'foo'
b = ['foo', 'bar', 'baz']
c = ['bar' ,'baz']

print(f'{a} in {b}? ', a in b)
print(f'{a} in {c}? ', a in c) 

The result of the function can be used directly to enter an if statement.
Rather do this:

if a in b:
    pass

Than this:

if (a in b) == True:
    pass

====== end of message =====

Potentially also part of the message, although I’m not too sure if it is the best way to do things:

=== optional ====
If a is a list we have to use all():

a = ['foo', 'bar']
b = ['foo', 'bar', 'baz']

# Checks if all elements of a are in b.
print(all([c in b for c in a]))

==== end ====

Have a goodie!
-korty.codes

@shtlrs shtlrs transferred this issue from python-discord/bot Apr 15, 2023
@shtlrs shtlrs added area: tags Related to the @Python bot's tags type: addition Request to add something new labels Apr 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: tags Related to the @Python bot's tags type: addition Request to add something new
Projects
None yet
Development

No branches or pull requests

2 participants