[Tutor] Strange problem
Andrei Kulakov
ak@silmarill.org
Mon, 12 Nov 2001 21:23:46 -0500
On Mon, Nov 12, 2001 at 06:54:11PM -0700, Mike Yuen wrote:
> I'll attach some code to make my question clearer.
>
> RowCol = sys.stdin.readline() # Gets Row / Col
> Row = RowCol[0]
>
> counter = 0
> for line in sys.stdin.readlines():
> line = string.strip(line)# Have clean line now
> if (counter == 0):
> key = line
> counter = counter + 1
> elif (counter < 4): ********* PROBLEM HERE! ***********
> data = line
> counter = counter + 1
> else:
> dict[key] = data
> counter = 0
>
> The problem occurs on the line i've indicated above. If I hardcode it by
> putting a 4 it works great and creates the dictionary items I want.
> However, when I put Row (which is: Row = RowCol[0]). The comparison
> operation doesn't work properly.
>
> Can someone helpe me out. I'm pretty stumped as to why.
>
> * I've put Row and RowCol[0] in place of the 4 above but it still doesn't
> work.
>
> Thanks,
> M
Umm.. RowCol[0] is a string, isn't it? You can convert it to an integer
like this:
val = int(RowCol[0]
>
>
> _______________________________________________
> Tutor maillist - Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
--
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org