Home > Blockchain >  How can I insert a string into quotations while keeping the string input in Python?
How can I insert a string into quotations while keeping the string input in Python?

Time:01-26

Random = (random.choice(Usernames))
print (str (Random))
studio.invite_curator (Random)

Text input in quotations is needed to complete the last line, yet I have a string that I need in the quotations. Is there any way to keep the quotations and the string in a new string variable?

This is just a piece of code from my project, but I know there are not any problems with the other parts I do not have shown.

I tried to use this script:

Random2 = '"',Random,'"'
studio.invite_curator (Random2)

But outputted as an error, because the final line of what I showed above needs to be in quotations. I can not yet find a way to work around this.

CodePudding user response:

Use string concatenation instead of commas.

Random2 = '"'   Random   '"'

CodePudding user response:

This will create a new string variable Random2 which contains the value of Random enclosed in quotation marks. Alternatively you could use f-strings to insert the variable into the string.

Random2 = f'"{Random}"' studio.invite_curator(Random2)

This will also create a new string variable Random2 which contains the value of Random enclosed in quotation marks.

  • Related