Q. Write a program to input a formula with some brackets and checks, and prints out if the formula has the same number of opening and closing parentheses.

 

Answer = 

 

formula = input("Enter the formula :-")
count_open = 0
count_close = 0

for i in formula :
    if i == "(" :
        count_open += 1
    elif i == ")":
        count_close += 1
if count_open == count_close :
    print("Correct formula")
else :
    print("worng")


6 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. hey prabu
    hey harinam krisna

    ReplyDelete
  2. what is this i cant understand a fucking thing

    ReplyDelete
    Replies
    1. pls maintain your language mr nethis from kikani cbe
      also home = ondipudur

      Delete
    2. dont do like aunty mr nethish sharma frm cbe

      Delete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post