newbie EOL while scanning string literal

rurpy at yahoo.com rurpy at yahoo.com
Tue Jun 25 19:44:40 EDT 2013


On 06/25/2013 04:19 PM, willlewis965 at gmail.com wrote:
> I'am starting to learn python reading a book and I have to do some
> exercises but I can't understand this one, when I run it it says EOL
> while scanning string literal and a red shadow next to a  line of
> code.
> 
> I'm trying to get input from user. I have 3 questions:
> 
> - Whats does EOL mean and in what circumstances can I face it again
> and how to avoid it.
> 
> - Is this code correct or just looks silly, I am a newbie in
> programming how can I write this code better OR is it just not right
> 'specify'.

You'll find some other errors in your code after you 
fix the string problem.  I'll leave them for you to find
since they're pretty obvious.

But one I'll mention because it is easy to miss because 
it produces wrong results rather than an error.

Try running your program with the input: 5, 5, 1 (which 
shouldn't be a triangle).

>      int(naa) 

int() *returns* the int value of naa, but doesn't change 
the value of naa which remains a string.

> - in how many ways can I specify the input has to be an integer, do I
> have to specify one by one or can I do something to get all input
> converted to integers in one step.

   naa = int (input ('type first integer\n'))

is still three steps but a little more concise.

Other ways are to put one input() call inside a loop
that runs three times, saving each input in an array.

Or you could read one string containing three numbers 
in one input statement, then split them into separate 
numbers.

These may require python stuff you haven't gotten to 
yet though.



More information about the Python-list mailing list