Merge pull request #270 from cclauss/patch-5

xrange() was removed in Python 3 in favor of range()
This commit is contained in:
Harshil 2018-03-19 09:00:22 +05:30 committed by GitHub
commit 5e21232e82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,12 @@
from __future__ import print_function
from math import sqrt
try:
xrange # Python 2
except NameError:
xrange = range # Python 3
def is_prime(n):
for i in xrange(2, int(sqrt(n))+1):
if n%i == 0:
@ -30,4 +36,4 @@ if __name__ == '__main__':
n = int(sys.argv[1])
print(sum_of_primes(n))
except ValueError:
print('Invalid entry - please enter a number.')
print('Invalid entry - please enter a number.')