Your implementation looks fine. This calculation is so trivial for a computer to do that it's not worth spending much time optimizing the implementation.
That said, the fact that you called print
without parentheses indicates that you are using Python 2. In Python 2, xrange()
would be slightly preferable to range()
xrange()
would be slightly preferable to range()
.
Alternatively, keep using range()
, and call print()
with parentheses to make your program compatible with Python 3.
Your implementation looks fine. This calculation is so trivial for a computer to do that it's not worth spending much time optimizing the implementation.
That said, the fact that you called print
without parentheses indicates that you are using Python 2. In Python 2, xrange()
would be slightly preferable to range()
.
Alternatively, keep using range()
, and call print()
with parentheses to make your program compatible with Python 3.
Your implementation looks fine. This calculation is so trivial for a computer to do that it's not worth spending much time optimizing the implementation.
That said, the fact that you called print
without parentheses indicates that you are using Python 2. In Python 2, xrange()
would be slightly preferable to range()
.
Alternatively, keep using range()
, and call print()
with parentheses to make your program compatible with Python 3.
Your implementation looks fine. This calculation is so trivial for a computer to do that it's not worth spending much time optimizing the implementation.
That said, the fact that you called print
without parentheses indicates that you are using Python 2. In Python 2, xrange()
would be slightly preferable to range()
.
Alternatively, keep using range()
, and call print()
with parentheses to make your program compatible with Python 3.