Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. # ! is negation, & is conjunction , / is disjunction , = is equivalence , > is implication
  2. #((PQ)/S)=T)
  3. v = input("enter your expression below: ")
  4. empty = []
  5. connections="!&/>="
  6. def funct1(w, pos):
  7. if pos>=len(v):
  8. return
  9. if(v[pos].isalpha()==True or connections.find(v[pos])!=-1):
  10. w.append(v[pos])
  11. funct1(w, pos + 1)
  12. elif(v[pos]=='('):
  13. new=[]
  14. w.append(new)
  15. funct1(new,pos+1)
  16. elif(v[pos]==')'):
  17. funct1(w, pos + 1)
  18. funct1(empty,0)
  19. print (empty)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement