python - appending dictionary to master list -


For some reason it is not allowing me to add a string item to a key in a dictionary

This is my code:

Example splitUserList (line) :

  gt; & Gt; & Gt;   

Code:

  def createUserList (): userList = [] Total User List = [] F = Open ("u.user.txt") For user, userDict = {} single user list = spit user list (line) userdict ["age"] = single user list [1] userdict ["gender"] = single user list [2] userdict ["business" ] = Single user list [3] single user ["zip"] = single user list [4] userList.append (userDict) returns userList   

Why is not it working? Traceback (most recent call final): file "/ applications / wingideapp / content / macus / src / debug / teas / server / _ sandbox", line 1, & lt; Module & gt; # Error file in the "File / Applications / WingIDAP / Content / MacS / SRC / debug / post / server / _ sandbox_jap", line 20, internally used for debug sandbox under external interpreter file: List index I should be assuming that

   

userDict ["zip"] = single user list [4]

  single user list ["zip"] = single Ughr list [4] # & lt; - Single user list list, # and you can not index it through string    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -