How can I get a list of the exponents of a polynomial? [closed]

I have a polynomial 1 + x^2 + x^4 + x^8 + x^9. I want a list of the exponents. {0,2,4,8,9}.

closed as off-topic by Daniel Lichtblau, user9660, Sjoerd C. de Vries, MarcoB, m_goldbergDec 28 '15 at 0:17

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Daniel Lichtblau, Community, Sjoerd C. de Vries, MarcoB, m_goldberg
If this question can be reworded to fit the rules in the help center, please edit the question.

• He is asking for Exponents not coefficients – Enrique Pérez Herrero Dec 27 '15 at 18:06

Try:

  Exponent[1 + x^2 + x^4 + x^8 + x^9, x, List]


Here you go!

Flatten[StringCases[
StringCases["1 + x^2 + x^4 + x^8 + x^9", "x" ~~ __], DigitCharacter]]


Now here is one you can use later:

Flatten[StringCases[
StringCases["polynomial goes here", "variable goes here" ~~ __], DigitCharacter]]

• And where is the 0 ??? – eldo Dec 27 '15 at 22:05
• @eldo sorry, I couldn't figure out how :( – benji b-k Dec 27 '15 at 22:33