Home > Mobile >  How to add multiple conditions to if statement?
How to add multiple conditions to if statement?

Time:01-12

I'm still new to python and am working on a program that is going fairly well. However, if-statements are my greatest weakness. I want to edit an if-statement.

it now says:

  # add 50 cents if paying with credit card
  if info.payment == UIPayment.CreditCard:
        price  = 0.50

but it needs to say something along:

if payment == creditcard (but value of payment is not 0):
price  = 0.50

If the value of payment is 0, there is no need to "price = 0.50"

CodePudding user response:

You can use logical operators and and or to combine conditions.

if payment == creditcard and price != 0:
    price  = 0.50
  •  Tags:  
  • Related