Jan-31-2019, 09:32 AM
The title makes this really confusing. Hopefully it isn't.
In the title I used 'X' and 'Y'. 'X' is a string url: https://i.imgur.com/7Ic4AMO.gifv and 'Y' is what I want to check for in the string.
Take this code:
I have also tried:
How can I work around this? Would changing the order of the if statement work?
Thanks,
Dream
In the title I used 'X' and 'Y'. 'X' is a string url: https://i.imgur.com/7Ic4AMO.gifv and 'Y' is what I want to check for in the string.
Take this code:
if '.gif' in X: print("HELLO") elif '.gifv' in X: print("PLEASE PRINT THIS")No matter if it has '.gif' or '.gifv' in the url, it will always print 'HELLO'. That occurs because '.gifv' also includes '.gif' so it never makes it to the next part of the if statement.
I have also tried:
X.endswith('.gifv') / X.endswith('.gif')but it always returns false.
How can I work around this? Would changing the order of the if statement work?
Thanks,
Dream