Help with dictionary, please

Tamito Kajiyama kajiyama at grad.sccs.chukyo-u.ac.jp
Fri Aug 6 10:04:17 EDT 1999


rbl at hal.cwru.edu writes:
| 
| 	if prev1 != '' and prev2 != '':
| 	 	   key = (prev2,prev1)
| 	           dict[key] = dict[key] + 1
|    and got this error:
| 	  File "Metro:Python 1.5.1:learn2.py", line 34
|           dict[key] = dict[key] + 1
|                          ^
| 	SyntaxError: invalid token
| 
| I'm obviously missing something here!

What you do seems good to me.  I wonder if you have trouble with white
space, since the code snippet shown above contains both space and tab
characters.

White space characters in indentation make sense in Python.  To avoid
mysterious syntax error, you'd better use either space or tab
characters, and not mix them.

Regards,

--
KAJIYAMA, Tamito <kajiyama at grad.sccs.chukyo-u.ac.jp>




More information about the Python-list mailing list