Issue
I'm trying to import a function called gcd from a module called fractions with from fractions import gcd
. For some reason, PyCharm throws an ImportError:
from fractions import gcd
ImportError: cannot import name 'gcd' from 'fractions'
I had this working before, what am I doing wrong?
Solution
Your traceback says Python 3.9 and the documentation says gcd is a function in math
Changed in version 3.9: The math.gcd() function is now used to normalize the numerator and denominator. math.gcd() always return a int type. Previously, the GCD type depended on numerator and denominator.
Answered By - lllrnr101
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.