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?
Try this:
i = 5
ii = 10
if i == 5 and ii == 10:
print "i is 5 and ii is 10"
Edit: Oh, and you dont need that semicolon on the last line (edit to remove it from my code).