-2

I wanna ask if we can put 2 or more conditions in single 'if' For example:

if a == 1 b == 2:
     print 'can we do this? If yes, how? '
John Kugelman
  • 349,597
  • 67
  • 533
  • 578

2 Answers2

1

If you want to check that both are true, use and:

if (a == 1) and (b == 2):

"If a equals 1 and b equals 2 ...".

Look up logical operators for other similar operations.

Carcigenicate
  • 43,494
  • 9
  • 68
  • 117
1

For both conditions to be true

if condition1 and condition2:

For one of the conditions to be true

if condition1 or condition2: