[Tutor] Re: number conversion problem (was: Re: [no subject])
Dragonfirebane at aol.com
Dragonfirebane at aol.com
Tue Jun 8 20:04:40 EDT 2004
In a message dated 6/8/2004 7:54:21 PM Eastern Daylight Time, dyoo at hkn.eecs.berkeley.edu writes:
> On Tue, 8 Jun 2004 Dragonfirebane at aol.com wrote:
>
> > In a message dated 6/8/2004 5:17:15 PM Eastern Daylight Time,
> > lsloan-000002 at umich.edu writes:
> >
> > > What do you expect the variable "char" to contain? A single character
> > > of the user's input string, one character at a time until you reach
> > > the end of the string?
> > >
> > > If so, you're going to need a line like this somewhere just before you
> > > reference "char":
> > >
> > > for char in original:
> >
> > I tried this, and it wouldn't let me run the program and highlighted the
> > closing quote as the culprit, claiming invalid syntax . . .
>
>
> Hi Dargonefirebane,
>
>
> Can you show us the exact error message? The most common occurrence of
> this error is due to mismatched quotes.
>
>
> Here is one example of such an error:
> ###
> >>> ['a','b','c','d','e','f','g', h']
> File "<stdin>", line 1
> ['a','b','c','d','e','f','g', h']
> ^
> SyntaxError: EOL while scanning single-quoted string
> ###
>
>
> A missing quote character will do this. And since the program has tables
> full of string constants, I wouldn't be surprised if one of the entries
> were mistyped.
>
> Computers are much much better about seeing syntax problems than us
> humans. If the Python system claims that there's a SyntaxError, then it's
> not just a claim: there IS a syntax error lurking somewhere in that
> program. *grin*
>
>
> Going back to the comment:
>
> > > for char in original:
> >
> > I tried this, and it wouldn't let me run the program and highlighted the
> > closing quote as the culprit, claiming invalid syntax . . .
>
> When the 'for' loop was first introduced into the program, it's all too
> easy to inadvertantly drop or introduce an extra quote. One extra
> character or one accidental backspace can do it. Computer programs are
> pretty finicky about details like this. It may be a stupid syntax error
> (like a missing quote), but that's something that's very easy to do, so I
> wouldn't take it personally.
>
>
> Try it again, and see if you get the same error message. If you ever see
> an error message that makes no sense, don't ignore it, but
> feel free to
> show it to the folks on Tutor.
I think you might have misunderstood. It highlighted the end quote on [reference 'char':]. And since the number converted works fine, the only other possible mis-typed quote would have to be in alphabet[] but there are none there.
"n thats the way the cookie crumbles"
America's Favorite Cookie
More information about the Tutor
mailing list