Discuss Small programme big help in the Python Programming forum on Dev Shed. Small programme big help Python Programming forum discussing coding techniques, tips and tricks, and Zope related information. Python was designed from the ground up to be a completely object-oriented programming language.
Time spent in forums: 11 m 7 sec
Reputation Power: 0
Originally Posted by b49P23TIvg
Python 2.7.3 (default, Sep 26 2012, 21:51:14)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
[10, 8, 6, 4, 2]
>>> a = list(range(10,0,-2))
>>> while a:
... del a
... if a:
... del a[-1]
thank you ver much "b49P23TIvg"
then 1st part of the question is ok now with you answer
what is the code for 2nd part
Write a phython Programme which prints the odd numbers between 1 and 1000 in tha following order..
Time spent in forums: 15 h 59 m 28 sec
Reputation Power: 2
I would approach this by making a list of all the odd numbers, I would do that by seeing if dividing it by an even number produces a float or not, if it doesn't produce a float then the number is even, right?
oddList = 
for i in range(1000):
no1 = float(i)/2
no2 = int(i/2)
if not no1==no2: oddList.append(i)
for i in range(len(oddList)):
That should do the trick. Just print oddList2 for the results. It will output the following (though I abbreviated this one with ........ obviously):