Post

PythonPython

S
Swetha Shetty

Posted on 5th March 2024|15 views

0
votes

Python While Loop Multiple Conditions

How can I make a while loop with multiple conditions in Python?

Answers
P
rushi chowdary

Posted on 5th March 2024

You can use or and and to make a while loop with multiple conditions like this

Using and:

A = 3

B = 4

While A<4 and B<5:

A+=1

B-=1

print(A,B)

Output:

2,3

Using or:

A = 2

B = 2

While A < 5 or B > 3:

A += 1

B -= 1

print(A, B)

Output:

3 1

4 0 

   

 

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo
  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos