Advertisement
vadim_sharaf

Untitled

Sep 21st, 2021
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. a, b, c = map(str, input().split())
  2. x, y = str, str
  3. s = str(a + '+' +  b + '*x' + '+' +  c + '*y')
  4. s1 = s.replace('1', '').replace('0*x', '').replace('0*y', '').replace('+-', '-').replace('+ a', 'a').replace('*', '').replace('0', '').replace('-+','-').replace('+-', '-').replace('++', '+').replace('--','+')
  5. if s1.count('+') != 0:
  6.     if s1.index('+') == 0:
  7.         s1 = s1[1:]
  8. if s1.count('+') != 0:
  9.     if s1.rindex('+') == len(s1)-1:
  10.         s1 = s1[:-1]
  11. if s1.count('-') != 0:
  12.     if s1.index('-') == 0:
  13.         s1 = s1[1:]
  14. print(s1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement