How do I concatenate a boolean to a string in Python?

后端 未结 6 1299
别那么骄傲
别那么骄傲 2021-01-31 12:57

I want to accomplish the following

answer = True
myvar = \"the answer is \" + answer

and have myvar\'s value be \"the answer is True\". I\'m pr

6条回答
  •  情话喂你
    2021-01-31 13:50

    answer = “True”
    
    myvars = “the answer is” + answer
    
    print(myvars)
    

    That should give you the answer is True easily as you have stored answer as a string by using the quotation marks

提交回复
热议问题