I have the following code:
#Euler Problem 1
print \"We are going to solve Project Euler\'s Problem #1\"
euler_number = input(\'What number do you want
In Python, a for
loop loops using a series of values. These can be, for example, items in a list; or these can be values that come from an "iterator".
for i in 3
makes no sense in Python, as 3
is not a series of values.
To loop over a series of integers, use range()
or xrange()
.
How does the Python's range function work?
Here's the documentation for Python's for
syntax:
http://docs.python.org/2/reference/compound_stmts.html#for
It loops over any sequence of values, not just a sequence of numbers like in other languages.
Have fun learning Python, it's a great language. Also, the Project Euler challenges are fun, so stick with them, and don't give up!
You probably want this:
for i in range(1, euler_number + 1):