I have an empty string strLocation and I would like to insert the three variables x, y and z to make the string a location of a point which is (x,y,z). I know I cannot simply add 'x' 'y' and 'z' because that will just add the letters instead of the actual values they hold. What should I do?
Asked
Active
Viewed 58 times
1
-
possible duplicate of [How to print a string followed by the result of a function in Python](http://stackoverflow.com/questions/30076273/how-to-print-a-string-followed-by-the-result-of-a-function-in-python) – kylieCatt Aug 20 '15 at 14:43
-
1possible duplicate of [Python string formatting: % vs. .format](http://stackoverflow.com/questions/5082452/python-string-formatting-vs-format) – mkrieger1 Aug 20 '15 at 14:46
2 Answers
2
Something like
strLocation = "("+str(x)+","+str(y)+","+str(z)+")"
?

Arkantus
- 120
- 1
- 10
-
@Kroltan It doesn't, see [this question](http://stackoverflow.com/questions/32121115/python-implicit-conversion-of-object-to-str/32121506#32121506) for someone having that problem. – SuperBiasedMan Aug 20 '15 at 15:19
-
@SuperBiasedMan Thanks for the reference. Been using Javascript for too long :) – This company is turning evil. Aug 20 '15 at 15:19