0

How do I make this string of printed python text bold (python IDLE v.3.10.5 windows 10):

subtotal = total_price * 1.20
print("The price for your custom pizza is £" , total_price)

I have tried looking it up on the web but I cannot find much. Please help :-)

Sam F
  • 11
  • 1
  • It depends on which console/OS you're using. On windows, I think it's tricky to make it work. That answer is good if the OP is using Linux. – Carl HR Nov 10 '22 at 18:24
  • 1
    Just for clarity's sake: Are you asking how to cause *python* to print bold text, or are you asking how to get *idle* to display bold text? – MDeBusk Nov 10 '22 at 18:26

1 Answers1

-2

try this :

print('\033[1m' + "The price for your custom pizza is £"+ '\033[0m',total_price)
Abhimanyu Sharma
  • 858
  • 1
  • 9
  • 17
  • This answer is good for a Linux environment. The OP wants an answer that works on Windows 10. I use windows. If I try to print your answer, using *total price as 123*, the console prints `[1mThe price for your custom pizza is £[0m 123`. In another words, the console does not accept these special characters. – Carl HR Nov 10 '22 at 18:38
  • @CarlHR it works on git bash – Abhimanyu Sharma Nov 11 '22 at 06:37
  • 1
    Yes, on applications that simulate a linux environment, it might work, such as MSYS for example. But on *the windows console* and *idle for windows* it doesn't. – Carl HR Nov 11 '22 at 10:13
  • 1
    Before I wrote this comment I did test all cases to see if it was really true. On MSYS the font becomes bold. But on the windows console or idle, the special characters are not parsed by the console. – Carl HR Nov 11 '22 at 10:17