{"record":{"id":"1d26d056b7745746","repo":"TheAlgorithms/Python","slug":"i-not-in-list-of-symbols","errorCode":null,"errorMessage":"'{i}' not in list of symbols","messagePattern":"'(.+?)' not in list of symbols","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"ciphers/enigma_machine2.py","lineNumber":150,"sourceCode":"    # a) is type string\n    # b) has even length (so pairs can be made)\n    if not isinstance(pbstring, str):\n        msg = f\"Plugboard setting isn't type string ({type(pbstring)})\"\n        raise TypeError(msg)\n    elif len(pbstring) % 2 != 0:\n        msg = f\"Odd number of symbols ({len(pbstring)})\"\n        raise Exception(msg)\n    elif pbstring == \"\":\n        return {}\n\n    pbstring.replace(\" \", \"\")\n\n    # Checks if all characters are unique\n    tmppbl = set()\n    for i in pbstring:\n        if i not in abc:\n            msg = f\"'{i}' not in list of symbols\"\n            raise Exception(msg)\n        elif i in tmppbl:\n            msg = f\"Duplicate symbol ({i})\"\n            raise Exception(msg)\n        else:\n            tmppbl.add(i)\n    del tmppbl\n\n    # Created the dictionary\n    pb = {}\n    for j in range(0, len(pbstring) - 1, 2):\n        pb[pbstring[j]] = pbstring[j + 1]\n        pb[pbstring[j + 1]] = pbstring[j]\n\n    return pb\n\n\ndef enigma(\n    text: str,","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/TheAlgorithms/Python/blob/f5988cc09713315817df6a7e327e258013a94440/ciphers/enigma_machine2.py#L132-L168","documentation":"Raised by _plugboard() when a symbol in the plugboard string is not in the Enigma alphabet (uppercase A-Z). Lowercase letters, digits, punctuation, or spaces all fail because abc contains only the 26 uppercase letters.","triggerScenarios":"_plugboard('pictures') in lowercase; 'PICTUR3S' with a digit; a space inside pairs like 'PI CT' — spaces are not actually stripped and are not in abc.","commonSituations":"Accepting user input without uppercasing; copy-pasted settings with whitespace; settings from another alphabet convention.","solutions":["Uppercase and strip spaces before calling: _plugboard(pb.upper().replace(' ', ''))","Use only A-Z symbols in pairs","Pre-validate every char with all(c in string.ascii_uppercase for c in pb)"],"exampleFix":"# before\n_plugboard('pictures')  # lowercase fails\n\n# after\n_plugboard('PICTURES')","handlingStrategy":"validation","validationCode":"import string\npb = pb.upper().replace(' ', '')\nassert all(c in string.ascii_uppercase for c in pb)","typeGuard":"def is_uppercase_alpha(pb: str) -> bool:\n    return all(c.isalpha() and c.isupper() for c in pb.replace(' ', ''))","tryCatchPattern":"try:\n    pbdict = _plugboard(pb)\nexcept Exception as exc:\n    if \"not in list of symbols\" in str(exc):\n        pbdict = _plugboard(pb.upper().replace(' ', ''))\n    else:\n        raise","preventionTips":["Uppercase and strip spaces before calling _plugboard","Restrict plugboard input to A-Z","Validate against string.ascii_uppercase in your input form"],"tags":["enigma","plugboard","alphabet","validation"],"backgroundTag":null,"analyzedSha":"f5988cc09713315817df6a7e327e258013a94440","analyzedAt":"2026-08-14T17:30:07.041Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}