I'm trying to set up a bot that deletes messages if they include a specific string from a list anywhere in their body.
This code works exactly how I think it should: (returns True)
s = 'test upvote test'
upvote_strings = ['upvote', 'up vote', 'doot']
print(any(x in s for x in upvote_strings))
But this does not: (returns False)
s = 'your upvotе bot thing works fine lmao'
upvote_strings = ['upvote', 'up vote', 'doot']
print(any(x in s for x in upvote_strings))
If a method does not return a value, it must be declared to return void . However, the pop() method in the Stack class returns a reference data type: an object. Methods use the return operator to return a value. Any method that is not declared void must contain a return statement.
A method does not have to return something, but all methods need to have a return type. The return type tells Java what type of value it can expect the method to return, the void type is just there to tell Java that the method does in fact not return anything.
Java is protecting you from having possible executions that would miss the return statement entirely. e.g. print(0, 5, fillcharac); In this case, the outer loop would never execute and the method would immediately exit, but Java would have no idea what the method should return.
In Python, it is possible to compose a function without a return statement. Functions like this are called void, and they return None, Python's special object for "nothing".
One of those e is not ASCII:
>>> import unicodedata
>>> unicodedata.name(s[10])
'CYRILLIC SMALL LETTER IE'
>>> unicodedata.name(upvote_strings[0][-1])
'LATIN SMALL LETTER E'
unidecode
can help:
>>> e1 = s[10]
>>> e2 = upvote_strings[0][-1]
>>> e1 == e2
False
>>> from unidecode import unidecode
>>> unidecode(e1) == "e" == unidecode(e2)
True
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With