[Tutor] Python type confusion?
Mark Lawrence
breamoreboy at yahoo.co.uk
Tue Sep 29 03:18:31 CEST 2015
On 28/09/2015 21:27, Ken Hammer wrote:
As you've all ready had answers I've just one thing to say below.
> total = 0.0
> for i in range(len(poly)):
> totalTerm = poly[i]* (x ** i)
> total += totalTerm
> print "totalTerm ", i , totalTerm
> print "Equation Value", total
>
Perhaps the most used piece of code that although not actually wrong, is
certainly frowned upon as you can write:-
for i, item in enumerate(poly):
totalTerm = item * (x ** i)
...
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
More information about the Tutor
mailing list