-2

never had such a problem and do not know how to solve or even call it...

types = [105000, 105001, 105002, 105003, 105004, 105005, 105006, 105007]
for type in types:
    print type

prints only

105000
105002
105004
105006

but I don't know why.

using a function to generate an array from input like

self.arrSplit(105000,105001,105002,105003,105004,105005,105006,105007)

function:

    def arrSplit(self, arr):
        itms = []
        for it in arr.split(','):
            tt = it.split('-')
            if (len(tt) >= 2 and int(tt[0]) < int(tt[1])):
                for i in range(int(tt[0]), int(tt[1])+1):
                    itms.append(i)
            else:
                itms.append(int(tt[0]))
        return itms

to complete this the code looks like this (its the minimum)

types = self.arrSplit(105000,105001,105002,105003,105004,105005,105006,105007)
print types
for type in types:
print type

prints:

[105000, 105001, 105002, 105003, 105004, 105005, 105006, 105007]
105000
105002
105004
105006
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
NoLand
  • 39
  • 7
  • That is not possible. Are you sure that this is the code that produce that output? – styvane Mar 05 '16 at 10:35
  • Works just fine for me... Your indentation is broken, though, but I guess that's an artefact of how you put it on SO – Chris Kitching Mar 05 '16 at 10:35
  • Please give the input (is that the '1,2,3,4' you mention?), the expected return value and the actually return value of `arrSplit`. – das-g Mar 05 '16 at 10:45
  • input to that function is 105000,105001,105002,105003,105004,105005,105006,105007 when i print it to console it is showing me it right but when i loop through its only getting every 2nd element wich is weird – NoLand Mar 05 '16 at 10:48
  • Are you using a 64bit executable on a 32bit OS ? – Arif Burhan Mar 05 '16 at 15:07
  • No i am connecting via ssh to my debian7 vp-server, never had problems before when i used this function, only now and only there – NoLand Mar 05 '16 at 16:49

1 Answers1

0

For the for loop you should use this:

types = [105000, 105001, 105002, 105003, 105004, 105005, 105006, 105007]
for numbers in types:
    print numbers

This worked for me, but I can't explain why it only printed evens.

Ɖiamond ǤeezeƦ
  • 3,223
  • 3
  • 28
  • 40
Matt Jones
  • 16
  • 4