Abdul Khan
Abdul Khan

Reputation: 67

Why do i get SyntaxError: unexpected EOF while parsing when i run this code?

    s = input(' Enter a monomial: ')
    coeff, power = s.partition('x^')
    print('{}x^{}'.format(int(coeff) * int(power), int(power) - 1)

I do not know what else is needed at the end of this code. Is there something that needs to be added in?

Upvotes: 1

Views: 503

Answers (2)

Deilusia
Deilusia

Reputation: 21

You missed a bracket in last line:

print('{}x^{}'.format(int(coeff) * int(power), int(power) - 1))

Upvotes: 1

Brad Figueroa
Brad Figueroa

Reputation: 875

It's because you're not closing print function, one a close parenthesis at the end is missing. I suggest you to use some linter to debug and find warning and errors. The final code should be as below:

s = input(' Enter a monomial: ')
coeff, power = s.partition('x^')
print('{}x^{}'.format(int(coeff) * int(power), int(power) - 1))

Upvotes: 2

Related Questions