Back

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

Hi all, I want to know how to go about using Boolean operation in Python.

I have tried this but I have an error: 

i = 5

ii = 10

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

    print "i is 5 and ii is 10";     

But I get a syntax error. All help appreciated!

2 Answers

0 votes
by (300 points)

Hi. Go about doing this and you will achieve your goal.

Code: 

a = 5

aa = 10

if a == 5 and aa == 10:

      print "a is 5 and aa is 10"

Hope this helps!


 

0 votes
by (106k points)
edited by

For doing OR and AND operation in Python we use 'or' and 'and' keywords, What you have used is not valid in Python. To get rid of the error follow the below-mentioned way:-

if i == 5 and ii == 10:

     print("i is 5 and ii is 10")

To know more about this you can have a look at the following video tutorial:-

Related questions

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

Browse Categories

...