I would like to apply vocal_start
to so many different variables and i can't handle them all and i wouldn't always repeat startswith
. So I don't want to write variable1.startswith(("a", "e", "i", "o", "u"))
, but i would like to apply startswith(("a", "e", "i", " o", "u")) directly to all variables without specifying variable1.startswith
(something similar to my code). I wouldn't always repeat startswith
I guess using startswith
is only like this (variable1.startswith), so is there anything else I can use? I need something like my code, but not with startswith (or I'd like to use startswith differently if possible)
vocal_start = startswith(("a", "e", "i", "o", "u"))
variable1 = "open"
#Only for Test
if variable1 == vocal_start:
print("correct")
In the code, of course, I get the NameError: name 'startswith' is not defined
because I didn't specify variable1.startswith(("a", "e", "i", "o", "u")), but as I said, I don't want to go this route
source https://stackoverflow.com/questions/75860763/how-can-i-use-startswith-without-specifying-a-certain-string-is-there-any-alter
Comments
Post a Comment