The title is a bit vague, but I'll explain it.
I'd like to give you a string as a condition in the Python if statement, but I'd like to give you two strings as a condition.
ex:
url = raw_input('>')
if 'http://' or 'https://' in url:
print 'true'
else:
print 'false'
For example, it's the same way as above. If I do it like that, it's always true.
>http://www.naver.com
true
>https://www.naver.com
true
>1234
true
It would be possible to write the if statement repeatedly, but I'm asking if there's a way to do it in one line.
python
You seem to want to start with http://
or start with https://
.
url = raw_input('>')
if url.startswith('http://') or url.startswith('https://'):
print 'true'
else:
print 'false'
Try it as above.
© 2024 OneMinuteCode. All rights reserved.