not with strings

You can also use the not operator to check if a string is empty.

In the below programme we check if name variable is empty we inform name is empty or we greet the person

            name = ""
if (not name) :
   print("Assign value to name variable")
else :
  print ("Hi "+name)
            

Discount Voucher

A customer wants to buy a product which is of price 200 in dollars. He has to pay extra 20 dollars for shipping, if he does not apply discount voucher.

Print the total amount that the customer has to pay after applying the discount voucher.

                price = 200
coupon_code = "10SALE"
print(price + (not coupon_code) * 20)