Can you use "\" in a dictionary inside Python?

59 views Asked by At

I'm creating a variation of the vigenere cipher using all the ASCII characters using a dictionary. The first few lines are okay, but then I get an error for the value 3. vigenereDictionary = { "@": "0", "%": "1", "+": "2", "\": "3", "/": "4", ... I want to have it so that when a user types \ it will output/take the value 3, however, I understand backslash is a special character, is there any way to implement this.

1

There are 1 answers

0
Kai On

" It's an escape character for a string, try using "\", which escapes the backslash itself. – ChrisOram "