Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Could someone please explain why did they use "&" and why not "and"?I tried usin...

Sri Harsha Bandarupalli

Sep 13, 2022

Could someone please explain why did they use "&" and why not "and"?

I tried using "and" i had got a different answer, instead of 1 and 2 i got 2 and 2.

Can someone please explain this?

1

0

Comments
Comments
S
Sri Harsha Bandarupalli3 years ago

I looked in google and think this might be the problem.

"and" operator is a lazy operator therefore it first evaluates left operand and if the result is False it ignores right hand side operand and return the result as 'False'. Because of this i think the function th...

On this page