myStr = "domain" myVal = "pythonforbeginners.com" myTemplate = "{} = "{}"" statement = myTemplate.format(myStr, myVal) exec(statement) print(domain)