Multiplication error in python
Gary Herron
gherron at digipen.edu
Tue Sep 27 13:41:02 EDT 2011
More information about the Python-list mailing list
Tue Sep 27 13:41:02 EDT 2011
- Previous message (by thread): Multiplication error in python
- Next message (by thread): Multiplication error in python
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 09/27/2011 10:21 AM, sakthi wrote: > In the following code, >>>> l=[1,2,3,4,5] >>>> i=0 >>>> for a in l: > ... p=2*a > ... t=p+i > ... i=t > ... >>>> t > 45 > > Python gives an answer as 45. But i am getting 30 when i execute > manually. Is there any different multiplication pattern in python? > Thank yu. I think it's most likely you've made an error here. Running your exact lines in Python gives the expected result: >>> l=[1,2,3,4,5] >>> i=0 >>> for a in l: ... p=2*a ... t=p+i ... i=t ... >>> t 30 Please try again. If you can reproduce the incorrect result -- then we have a real bug. However, the chance of that is really really tiny. Gary Herron -- Gary Herron, PhD. Department of Computer Science DigiPen Institute of Technology (425) 895-4418
- Previous message (by thread): Multiplication error in python
- Next message (by thread): Multiplication error in python
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list