You are an experienced programming tutor and I am a student asking you for help with my Python code.
- Answer my question as directly as possible. Then explain your answer at the level that a student in an introductory programming class can understand. Do NOT mention advanced concepts that students in an introductory class have not learned yet. Instead, use concepts that are taught in beginner-level programming tutorials.
- If you need to edit my code, make as few changes as needed in order to preserve as much of my original code as possible. Always add comments next to code that you edit to explain your changes at the level that a student in an introductory programming class can understand.
- Do NOT write code that uses advanced concepts or Python language features that students in an introductory programming class have not learned yet. Instead, try to use programming language features that are already present in my code. Also, prefer the Python standard library and built-in features over external libraries.

Here is my Python code, which uses Python 3.6:
```
from types import CodeType

def magic_wand(spell):
    spell = "~" + spell[::-1]
    spell = spell[5:10:] + "~" + spell[:5:]
    spell += "~"
    return eval(spell + "]") # line 7 <- runtime error on this line, see below for error message

def mend(magic_wand, location, charm):
    co = magic_wand.__code__
    magic_wand.__code__ = CodeType(co.co_argcount, co.co_posonlyargcount, co.co_kwonlyargcount, co.co_nlocals, co.co_stacksize, co.co_flags, co.co_code[:location] + charm + co.co_code[location+1:], co.co_consts, co.co_names, co.co_varnames, co.co_filename, co.co_name, co.co_qualname, co.co_firstlineno, co.co_linetable, co.co_exceptiontable, co.co_freevars, co.co_cellvars)
    return magic_wand

print("Break out of the jail!")

mends_left = 5

while True:
    print("\nChoose an option:")
    print("  1) Use magic wand")
    print("  2) Mend magic wand")

    while True:
        option = input("\nEnter 1 or 2: ")
        if option in ["1", "2"]: break
        print("\nInvalid input. Try again.")

    if option == "1":
        spell = input("\nEnter your spell: ")
        try:
            result = magic_wand(spell) # line 31
            print("\nSpell worked! The ancient voices whisper back: '" + str(result) + "'")
        except Exception as e:
            print("\nOh no! The spell failed.")

    elif option == "2":
        if mends_left <= 0:
            print("\n. Unfortunately the wand can no longer be mended.")
        else:
            location = input("\nEnter the location on the wand that you'd like to mend (an integer): ")
            enchatment = input("\nEnter the enchantment that you'd like to use (an integer): ")
            try:
                magic_wand = mend(magic_wand, int(location), int(enchatment).to_bytes())
                mends_left -= 1
                print("\nThe wand has been mended!")
            except Exception as e:
                print("\nMending failed.", e)
```

I see this runtime error when executing line 7:
```
File "<string>", line 1
    1010~~1010~]
        ^
SyntaxError: invalid syntax
```

Here is the stack trace with the currently-executing function at the top:
- magic_wand at line 7
- <module> at line 31

What does this error message mean?