-2

I created dictionary in python like below:

flip= {'0': 'a"', '1':'b"', '2':'c"'}

But I don't want to use double quotes. I need elements with single quotes. How can I do something like below? I was trying with \\, \, but it seems not to work.

Correct dict should look like below:

flip= {'0': 'a'', '1':'b'', '2':'c''}
Daniel Roseman
  • 567,968
  • 59
  • 825
  • 842
Tatarinho
  • 715
  • 2
  • 9
  • 28
  • In the linked duplicate, it is explained for double quote. `"`. Similar approaches are applicable for single quotes `'` as well. It is explained in accepted answer to the linked post – Moinuddin Quadri Jan 19 '17 at 11:37
  • The dictionary is irrelevant to the question. See how to create a [mcve]. – Peter Wood Jan 19 '17 at 11:49

2 Answers2

4

You can simply use double quotes around the element.

lip= {'0': "a'", '1':"b'", '2':"c'"}
Daniel Roseman
  • 567,968
  • 59
  • 825
  • 842
3

Using backslash should work, have you tried below?

flip= {'0': 'a\'', '1':'b\'', '2':'c\''}
Cleared
  • 2,372
  • 15
  • 32