Skip to content

xrange() was removed in Python 3 in favor of range() #270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Project Euler/Problem 10/sol1.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -30,4 +36,4 @@ def sum_of_primes(n):
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.')