Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (20.3k points)

In C# we can use && (boolean and) like this:

int i = 5;

int ii = 10;

if(i == 5 && ii == 10) {

    Console.WriteLine("i is 5, and ii is 10");

}

Console.ReadKey(true);

But try that with python:

i = 5

ii = 10

if i == 5 && ii == 10:

    print "i is 5 and ii is 10";      

I get an error: SyntaxError: invalid syntax

If I use a single &, at least I get no syntax error. How do I do a boolean && in Python?

1 Answer

0 votes
by (20.3k points)

You can try using the code given below:

i = 5

ii = 10

if i == 5 and ii == 10:

print "i is 5 and ii is 10"

Related questions

0 votes
1 answer
0 votes
2 answers
0 votes
1 answer
asked Sep 23, 2019 in Python by Sammy (47.6k points)
0 votes
1 answer

Browse Categories

...