You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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}? ', ainb)
print(f'{a} in {c}? ', ainc)
The result of the function can be used directly to enter an if statement.
Rather do this:
ifainb:
pass
Than this:
if (ainb) ==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([cinbforcina]))
==== end ====
Have a goodie!
-korty.codes
The text was updated successfully, but these errors were encountered:
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
The result of the function can be used directly to enter an if statement.
Rather do this:
Than this:
====== 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()
:==== end ====
Have a goodie!
-korty.codes
The text was updated successfully, but these errors were encountered: