Jump to content

Dicrionary python error

Go to solution Solved by thiagosch,

you're missing commas (separating each dictionary) and the closing "}" at the end of the main dictionary

pswdic = {
  "A" : {
    "Username" : "AB1",
    "Password" : "12345"
  },
  "B" : {
    "Username" : "Cool1",
    "Password" : "qwerty!"
  },
  "C" : {
    "Username" : "No_scope",
    "Password" : "nO-ScOpE"
  },
  "D" : {
    "Username" : "Elite007",
    "Password" : "IAmSuperCool1"

  }
}

don't forget that not only A B C and D are dict, pswdic also is dict, so you have a dict of dicts, if you think of it like this:

D_A = {"user":"test"}
D_B = {"user":"test2"}
D_C = {"user":"test3"}
pswdic = {
          "A":D_A,
          "B":D_B,
          "C":D_C
          }

could make it easy to understand
 

Saludos!

pswdic = {
  "A" : {
    "Username" : "AB1",
    "Password" : "12345"
  }

  "B" : {
    "Username" : "Cool1",
    "Password" : "qwerty!"
  }
  "C" : {
    "Username" : "No_scope",
    "Password" : "nO-ScOpE"
  }

  "D" : {
    "Username" : "Elite007",
    "Password" : "IAmSuperCool1"

  }

Its giving me an error at line 2 at the first {. I dont know how to fix it, can someone please help?

Link to comment
https://linustechtips.com/topic/1515217-dicrionary-python-error/
Share on other sites

Link to post
Share on other sites

you're missing commas (separating each dictionary) and the closing "}" at the end of the main dictionary

pswdic = {
  "A" : {
    "Username" : "AB1",
    "Password" : "12345"
  },
  "B" : {
    "Username" : "Cool1",
    "Password" : "qwerty!"
  },
  "C" : {
    "Username" : "No_scope",
    "Password" : "nO-ScOpE"
  },
  "D" : {
    "Username" : "Elite007",
    "Password" : "IAmSuperCool1"

  }
}

don't forget that not only A B C and D are dict, pswdic also is dict, so you have a dict of dicts, if you think of it like this:

D_A = {"user":"test"}
D_B = {"user":"test2"}
D_C = {"user":"test3"}
pswdic = {
          "A":D_A,
          "B":D_B,
          "C":D_C
          }

could make it easy to understand
 

Saludos!

Edited by thiagosch
added explanation
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×