On Sat, Aug 13, 2022 at 6:06 AM Zohreh Karimzadeh <z.karimza...@gmail.com>
wrote:

> Dear sympy
> Thank millions  for sharing and caring!
> I need to create and use symbols in dynamic way. Infact symbols are made
> based on user input and used in code so I must use f'strings to make them.
> As shown below:
> L=[ 'xCl', 'xNa']
> for j in range(len(L)):
>      locals()[L[j]] = sympy.symbols(L[j])
> ss = xCl * xNaCl
> i = 'Na'
> j='Cl'
> gg =f"x{i}"* f"x{j}"
> print('gg', gg)
> But I got the following error
> TypeError: can't multiply sequence by non-int of type 'Symbol'
> Could possibly let me know how can do it??
>

You are trying to multiply the strings but you really want to multiply
symbols. Something like Symbol(f"x{i}")*Symbol(f"x{i}").

There should be no need to inject symbols into locals to do what you are
trying to do. Symbols do not have to be assigned to a variable to work.

Aaron Meurer

-- 
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/6e80be54-2134-460f-9125-08f0d99def73n%40googlegroups.com
> <https://groups.google.com/d/msgid/sympy/6e80be54-2134-460f-9125-08f0d99def73n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6Lbbaid_unUZMHyO2MAhXfNvcwQdQW9sv4gjuZ2JFAFxQ%40mail.gmail.com.

Reply via email to