Is there a more elegant way to write this statement? I find myself writing ones similar quite a lot.
if ('.jpg' in imagename[0].lower() or '.png' in imagename[0].lower() or '.jpeg'
in imagename[0].lower()):
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You probably want
Note that
str.endswith()accepts a tuple of strings. Also note that this code is not equivalent to yours, since it only checks for the mentioned strings at the end of the filename, but chances are that this is your intention.