-2

I was just wondering if it is possible to add an apostrophe in this situation. I want the test key to have the value of "I don't know" not "I don". Is it possible to do so? If so how?

 my_dict = {
    "test": 'I don't know'
}
Dqnny
  • 11
  • 4

2 Answers2

3

You can either wrap the value in double quotes:

{"test": "I don't know"}

or escape the apostrophe:

{"test": 'I don\'t know'}
snahor
  • 1,162
  • 1
  • 10
  • 16
Matt
  • 646
  • 4
  • 11
0

You can do either of two things. You can to this:

my_dict = {
    "test": "I don't know"
}

or you can also do this:

my_dict = {
    "test": 'I don\'t know'
}

Either works and both are pretty much the same.

jath03
  • 2,029
  • 2
  • 14
  • 20