+ 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 Respuestas
+ 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