Re: problems with looping, i suppose

2006-04-05 Thread Lawrence D'Oliveiro
In article <[EMAIL PROTECTED]>, John Salerno <[EMAIL PROTECTED]> wrote: >... and now when I run >it, the DOS prompt flashes real quick and disappears. Does your DOS OS not have the equivalent of xterm, or KDE Konsole, or such? Something that lets you execute more than just one command, so you

Re: problems with looping, i suppose

2006-03-28 Thread John Salerno
Sion Arrowsmith wrote: > John Salerno <[EMAIL PROTECTED]> wrote: >> Does what I originally pasted in my message look incorrect? To me, it >> all seems indented properly. > > Yes. Somewhere or other you've got your tabstop set to 4, and python > treats literal tabs as being of equivalent indent t

Re: problems with looping, i suppose

2006-03-28 Thread Sion Arrowsmith
John Salerno <[EMAIL PROTECTED]> wrote: >Does what I originally pasted in my message look incorrect? To me, it >all seems indented properly. Yes. Somewhere or other you've got your tabstop set to 4, and python treats literal tabs as being of equivalent indent to 8 spaces. As does my newsreader,

Re: problems with looping, i suppose

2006-03-27 Thread John Salerno
[EMAIL PROTECTED] wrote: > Ok I felt a little bad for my quick answer, these just seem like > homework problems. NP. I appreciate your help. These are just little exercises I found online, just to give me a reason to use Python. :) -- http://mail.python.org/mailman/listinfo/python-list

Re: problems with looping, i suppose

2006-03-27 Thread Scott David Daniels
John Salerno wrote: > Here's another question that is related: > > while True: > year = raw_input('Enter year (or other character to quit): ') > try: > year = int(year) > except NameError: > break > ... > raw_input() > > This works as expected, except that if you e

Re: problems with looping, i suppose

2006-03-27 Thread John Salerno
Gary wrote: > 0 Alignment problem with the "except" clause. > As I'm sure you've already discovered, Python is "whitespace > sensitive". Wow, I'm really confused. As it turns out, whitespace *was* the problem, but it looks no different now (as it works) than it did then (when it didn't work

Re: problems with looping, i suppose

2006-03-27 Thread Gary
John -- I looked at your exercise. As it appears in my browser, there appear to be a couple of problems with the bottom "While" block. 0 Alignment problem with the "except" clause. As I'm sure you've already discovered, Python is "whitespace sensitive". If it looks like a block, it is; other

Re: problems with looping, i suppose

2006-03-27 Thread [EMAIL PROTECTED]
Ha, you found it all before I could fire it up. The whitespace thing is very odd, and it took about a month before I was comfortable using it for scope. On the bright side, scope errors are a lot easier to find than you might think, once you get used to looking at py code. I thought, if your in t

Re: problems with looping, i suppose

2006-03-27 Thread [EMAIL PROTECTED]
Ok I felt a little bad for my quick answer, these just seem like homework problems. first problem - it's scope. (there are two scope errors in the sample) white space is meaningful. get consistent with tabs or spaces, or choose an editor that replaces tab press with space. It'll make life a lot

Re: problems with looping, i suppose

2006-03-27 Thread John Salerno
John Salerno wrote: > I think it has to do with the exception I'm using. For the leap year > program, it should be ValueError. For the other one, its' a combination > of that and the input function. Hmm, turns out something was wrong with the indentation of the second while loop! Even though i

Re: problems with looping, i suppose

2006-03-27 Thread John Salerno
[EMAIL PROTECTED] wrote: > Just barely looked the code answer: > check you scope on the second try block. > > if that doesn't work... > I'll read it for real :) > > Try PyDev plugin with eclipse - it's served me fairly well, but I did > come from Java - so I'm an eclipse fan already. > I think

Re: problems with looping, i suppose

2006-03-27 Thread [EMAIL PROTECTED]
Just barely looked the code answer: check you scope on the second try block. if that doesn't work... I'll read it for real :) Try PyDev plugin with eclipse - it's served me fairly well, but I did come from Java - so I'm an eclipse fan already. -- http://mail.python.org/mailman/listinfo/python-

Re: problems with looping, i suppose

2006-03-27 Thread John Salerno
John Salerno wrote: > Here's an exercise I was doing to guess a number from 1-100. Here's another question that is related: while True: year = raw_input('Enter year (or other character to quit): ') try: year = int(year) except NameError: break if (year % 4 =

Re: problems with looping, i suppose

2006-03-27 Thread John Salerno
John Salerno wrote: > Here's an exercise I was doing This might help: import random number = random.choice(range(1, 100)) tries = 0 while True: try: guess = input('Enter a number between 1 and 100: ') break except NameError: print 'Invalid number\n' co