+ 1

How can I write text and a variable in a "print" command at the same time?

Example: variable = 0 print("Text:", variable) Output: Text: 0

11th Oct 2020, 12:09 PM
Royalx
Royalx - avatar
11 Answers
+ 3
You have to convert the var x to string like this x = 1 x = str(x) Please feel free to dm if you have any doubts, or u can post here, Royalx Music
11th Oct 2020, 12:25 PM
Steve Sajeev
Steve Sajeev - avatar
+ 3
I guess the answer ur Looking is this For python do: x = "This is string" print("Text: " + x)
11th Oct 2020, 12:17 PM
Steve Sajeev
Steve Sajeev - avatar
+ 3
Welcome
11th Oct 2020, 12:27 PM
Steve Sajeev
Steve Sajeev - avatar
11th Oct 2020, 12:13 PM
</๐šœ๐šŒ๐š˜๐š›๐š™๐š’๐š˜๐š—>
</๐šœ๐šŒ๐š˜๐š›๐š™๐š’๐š˜๐š—> - avatar
+ 1
x="something" print(x)
11th Oct 2020, 12:11 PM
๐Ÿ‡ฎ๐Ÿ‡ณVivek๐Ÿ‡ฎ๐Ÿ‡ณ
๐Ÿ‡ฎ๐Ÿ‡ณVivek๐Ÿ‡ฎ๐Ÿ‡ณ - avatar
+ 1
Thanks!!!!! ๐Ÿ˜๐Ÿ˜๐Ÿ˜
11th Oct 2020, 12:26 PM
Royalx
Royalx - avatar
0
I edited the description, there is an example.
11th Oct 2020, 12:15 PM
Royalx
Royalx - avatar
0
I understand did you mean x = "awesome" print("Python is " + x)
11th Oct 2020, 12:18 PM
</๐šœ๐šŒ๐š˜๐š›๐š™๐š’๐š˜๐š—>
</๐šœ๐šŒ๐š˜๐š›๐š™๐š’๐š˜๐š—> - avatar
0
Thank you guys :)) But it doesn't work if "x" is a number. ๐Ÿ˜
11th Oct 2020, 12:20 PM
Royalx
Royalx - avatar
0
Royalx Music welcome ๐Ÿ˜Ž
11th Oct 2020, 12:21 PM
</๐šœ๐šŒ๐š˜๐š›๐š™๐š’๐š˜๐š—>
</๐šœ๐šŒ๐š˜๐š›๐š™๐š’๐š˜๐š—> - avatar
0
you can also do print(fโ€Text: {variable}โ€) It works whether or not โ€˜variableโ€™ is an integer.
12th Oct 2020, 9:40 PM
thetechguy
thetechguy - avatar