-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
  • 588,541
  • 66
  • 880
  • 895
Tatarinho
  • 754
  • 2
  • 11
  • 31
  • 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
  • 588,541
  • 66
  • 880
  • 895
3

Using backslash should work, have you tried below?

flip= {'0': 'a\'', '1':'b\'', '2':'c\''}
Cleared
  • 2,490
  • 18
  • 35