Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 1 of 2

python getcontext invalid syntax

I'm just starting out with Python and following a guide to learn functions and modules.


I think I've done everything correctly here but I can't explain the syntax error for the getcontext command.


Any help is appreciated.

getcontext Syntax Error.png


1 Reply
Commander Lvl 2
Message 2 of 2

Re: python getcontext invalid syntax

This worked fine for me: (Python 3.6.8)

from decimal import getcontext

numberofdigits = int(input("Num of digits:"))
getcontext().prec = numberofdigits


Since your screenshot is cut off on the right, I'm wondering if there is something wrong in your "input" line?


Please follow-up to let us know how you made out. For good karma, mark a reply as the answer if it helped!