How to pass %
within a string variable to another cell where it is executed?
I define some code as a string and store in a variable where I have a magic function starting with a percentage sign.
I pass this string to another cell where I am trying to execute the code contained in the string.
The percentage sign used in the magic function gives me some problems. The sign is properly displayed in the created string but the execution breaks in the place where the %
is.
There is the example:
Cell_1:
string_variable = '%dirs'
Cell_2
print(string_variable)
output:
%dirs
Cell_3
exec(string_variable)
Error: % Invalid Syntax
I tried different ways like /%
%%
but no one worked.