fork download
  1. import re
  2.  
  3. poly = ("3x^2 - 3x - 3")
  4. s=re.sub('[xX^]','',poly)
  5. print([int('-'+i[0]) if s[s.index(i)-2]=='-' else int(i[0]) for i in re.split(' [+|-] ',s)])
Success #stdin #stdout 0.02s 27712KB
stdin
Standard input is empty
stdout
[3, 3, 3]