<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def create_variable(self, varname, vtype=None):
 """Create a tk variable. If the variable was created previously return that instance. """


        var_types = ('string', 'int', 'boolean', 'double')
        vname = varname
        var = None
        type_from_name = 'string'  # default type
        if ':' in varname:
            type_from_name, vname = varname.split(':')
            #  Fix incorrect order bug #33
            if type_from_name not in (var_types):
                #  Swap order
                type_from_name, vname = vname, type_from_name
                if type_from_name not in (var_types):
                    raise Exception('Undefined variable type in "{0}"'.format(varname))

        if vname in self.tkvariables:
            var = self.tkvariables[vname]
        else:
            if vtype is None:
                # get type from name
                if type_from_name == 'int':
                    var = tkinter.IntVar()
                elif type_from_name == 'boolean':
                    var = tkinter.BooleanVar()
                elif type_from_name == 'double':
                    var = tkinter.DoubleVar()
                else:
                    var = tkinter.StringVar()
            else:
                var = vtype()

            self.tkvariables[vname] = var
        return var