python - How do I fix a tuple in list error -


so have bit of code:

points = [ [400,100],[600,100],[800,100] , [300,300],[400,300],[500,300],[600,300] ,         [200,500],[400,500],[600,500],[800,500],[1000,500] , [300,700],[500,700][700,700][900,700] , [200,900],[400,900],[600,900] ] 

and produces error:

  line 43, in <module>     points = [ [400,100],[600,100],[800,100] , [300,300],[400,300],[500,300],[600,300] , [200,500],[400,500],[600,500],[800,500],[1000,500] , [300,700],[500,700][700,700][900,700] , [200,900],[400,900],[600,900] ] typeerror: list indices must integers, not tuple 

what can fix it?

you forgot 2 commas:

[500,700][700,700][900,700] 

now python sees attempt index list on left-hand side (700, 700) tuple:

>>> [500,700][700,700] traceback (most recent call last):   file "<stdin>", line 1, in <module> typeerror: list indices must integers, not tuple 

the second [900, 700] 'list' give same problem doesn't yet come play.

fix adding commas between:

[500, 700], [700, 700], [900, 700] 

or, complete list:

 points = [[400, 100], [600, 100], [800, 100], [300, 300], [400, 300], [500, 300], [600, 300], [200, 500], [400, 500], [600, 500], [800, 500], [1000, 500], [300, 700], [500, 700], [700, 700], [900, 700], [200, 900], [400, 900], [600, 900]] 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -