Format string | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Format string

When i code on my phone, i can use the %f, %s etc. To desplay results. Example X = 6 Y = 7 Print("The First number is %i, the last number is %i", %(x , y) and it will display (The First number is 6, the last number is 7) But when i code on my rbp, over Thonny Python, it dont Work..? How come?

18th May 2019, 8:18 PM
Rosenkilde
Rosenkilde - avatar
3 Answers
+ 1
You're welcome!
19th May 2019, 6:44 AM
Théophile
Théophile - avatar
+ 3
To format strings, you can use : x = 6 y = 7 print("x={0}, y={1}".format(x, y)) #outputs x=6, y=7
18th May 2019, 8:20 PM
Théophile
Théophile - avatar
+ 1
I Will try that! Thanks
18th May 2019, 8:37 PM
Rosenkilde
Rosenkilde - avatar