python - String + List in Python2 Function needed in Python3 -


there have been lot of questions asked/answered on how solve "typeerror: cannot concatenate 'str' , 'list' objects" error, getting. new python , taking online course being taught in python2.7 (i believe) writing in python 3.

this current code:

 print bcolors.bold + self.name + "     " + str(self.hp) + "/" + str(self.maxhp) + " |" + bcolors.okgreen + "███████             " + "|      " \           + str(self.mp) + "/" + str(self.maxmp) + " |" + bcolors.okblue + "██████" + bcolors.endc + "|" 

i know need change of + signs commas since there strings have tried every combination , losing hope.

any appreciated. i'm sorry if posted elsewhere did everywhere - lack of knowledge of python didn't allow me apply of other articles don't think.

i'm little confused question.

print "hello world" space in between python 2.7 syntax; python 3 uses print("hello world"). if commandline which python should let know python you're using interpreter.

also, in case, error means you're adding str , list together. variables not have str cast name , bcolors check these 2 variables see if lists. error may not @ line.

if want join items of list, correct syntax other answers have posted: ''.join([str(item) item in _list]).


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -