I have a function that takes multiple string arguments in the form of e.g. Subscription(items=["A", "B", "C"])
(quotation marks are mandatory, alphabet is just an example here). I don't want to write the arguments manually so I have a loop like
string=""
for letter in alphabet.values():
tmp="\"+letter+"\","
string=string+tmp
print(string) #only for debugging
Subscription(items=[string])
Unfortunately, this does not work, nothing happens. However, if I copy the string printed to the console and paste it into the items=[ ]
, it works. So the content seems to be fine but I suspect that something about the \"
formatting seems to be off when pasting the variable. I feel like I made a thinking mistake but I can't figure it out. Does anybody here have an idea?
source https://stackoverflow.com/questions/75999508/pass-a-string-with-quotation-marks-as-variable-in-python
Comments
Post a Comment