Logical Operators in (Str) Methods

Hello!
I’ve decided learning programming and started with python 2 days ago using the “Python for Everybody” course. I am currently in chapter 6 where he talks about strings and string methods. I have a question about using logic operators inside of a method call. When I use:

line = “Please”
x = line.startswith(“p” or “P”)
print(x)

the print statement returns false, although the line variable starts with a capital P. When i write it like this:

line = “Please”
x = line.startswith(“p”) or line.startswith(“P”)
print(x)

the print statement returns true. Can someone explain to me why I can’t use the “or” inside of the parameter brackets of the method and I have to write it separately?
Thanks in advance!

Kind regards

'p' or 'P' is logical expression that gets evaluated before function is called. Result of 'p' or 'P' is always 'p' so such function call is an equivalent of writing just: line.startswith('p')

Thank you for the fast answer! Will keep in mind that a logical expression always gets evaluated first when going on :slight_smile: