<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt">Well, to quote firefox: this is embarrassing. I've realized the dictionary initialization is wrong, as [] means its a tuple, I should use {}. That's why I don't like working nights..it's only in the morning when you start seeing things better. I apologize for the mail. Cheers<br><div><br></div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><font face="Tahoma" size="2"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> Vaduvoiu Tiberiu <vaduvoiutibi@yahoo.com><br><b><span style="font-weight: bold;">To:</span></b> python-list@python.org<br><b><span style="font-weight: bold;">Sent:</span></b> Fri, January 28, 2011 9:34:57 AM<br><b><span style="font-weight:
 bold;">Subject:</span></b> dictionary error:  list assignment index out of range<br></font><br>
<div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><div>Hy everyone, I'm trying to learng python for a week or two and there's a thing that is really disturbing me as I do not understand what the problem is. I'm trying to use a dictionary to remember when a user has visited a city. Code is really basic:<br><br>in the class init method I added<br>self.visited = []<br><br>and in the function where i check if city was visited:<br>cityNumber = 1 #example<br>if (not cityNumber in self.visited):<br>    #do some stuff<br>    self.visited[cityNumber] = "true"<br><br>Apparently the last line causes the error: list assignment index out of range. I read that this is the simplest way to assign a value to a dictionary(dict[key]=value). So why is the error appearing?? Thanks a lot in advance<br></div>
</div><br>







      </div></div>
</div><br>

      </body></html>