0
steave ray posted
TypeError: can only concatenate str (not
i am trying to concat two or more than string and integer value in print() function
a=1
print("hello world "+(str)a+" go to world")
i got following error for above code
TypeError: can only concatenate str (not "int") to str
so it tried to cast integer to string
a=1
print("hello world "+(str)a+" go to world")
and for above code for using (str) as to type cast and get error is:
[]bSyntaxError: invalid syntax[/b]
a=1
print("hello world "+(string)a+" go to world")
and for above code for using (string) as to type cast and get error is:
[]bSyntaxError: invalid syntax[/b]
so how to type cast integer to string with print() function in python?