Python - New beginner question, invalid syntax from a example file -


I am trying to learn Python myself, but I have failed on basic topics.

I am going through a set of examples from a book, and the first example was:

  import seri zero = ['***', '* *', '* *', '* *', '* *', '* *', '***'] = = ['*', '**', '*', '*' ,' * ',' * ',' * ** 'two' ['***', '* *', '* *', '*', '*', '*', '**** * '' Three = ['*** **', '*', '**', '*', '*', '* *', '**'] four = ['*', '* ',' * ',' * ',' ****** ',' * ',' * '] five = [' ***** ',' * ',' **** ',' * ',' * ', * * *', '***'] six = ['*', '*', '*', '****', '* *', '* *', '****'] seven = ['*****', '*', '*', '*', '*', '*', '*'] eight = ['***' , '* *', '* *', '***', '* *', '* *', '***'] nine = ['****', '* *', '* * ',' **** ', number' = ',' * ',' * '] = [zero, one, two, three, four, five, six, seven, eight, nine] Shish: points = sys.argv [1] row = 0 line & LT; 7: Line = '' column = 0 while column & lt; Lane (number): number = int (number [column]) points = points [number] line + = points [row] + '' column + = 1 print (line) row + = 1 except index: error: print ( 'Error: error (error,' in ',' digits ') except error' error: 'use: Bigdigits.py & lt; numbers & gt;')   

When I use bigdigits.py 1351355, I got an error, SyntaxError is saying: invalid syntax. I thought it was something wrong with the wrong path or something, I am using C: \ py3eg as the path to my programs. When I copied it to C: \ Python32 path, the same thing happened. I have also downloaded the code from the books website, and still get the error, so the code is properly alright.

This book is for Python 3 programming and I have Python version 3.2.1 installed.

If someone can tell me this error, then I would be very grateful!

Your code is in valid Python code 2.6+ and 3+. However, it generates the following error message in Python 2.5:

  File "syntax-error.py", except for line 31, valueError as err: ^ Syntax Error: Invalid syntax < / Code>  

This is because because Python 2.5 does not know the keyword like 2.5, you would instead use a comma:

  ValueError, err:   

Note that this will break Python 3.x compatibility.

P>

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -