2

Very new to python, so ignorance may be shown. (Python 3.10, Windows 10)

I have a simple code that tosses a coin. I want to underline the 'y' and 'n' in "yes" and "no" within this sentence: Do you want to flip another coin? yes or no.

I was able to make it work properly in IDLE, but it doesn't work properly when running in windows. The underline positions shifts to the left in Windows. I assume this is an issue in Windows, but can it be fixed? I'm simply double clicking the python file to run it in Windows, so maybe this is an incorrect way of doing it?

Here is the code for the sentence:

Yes = ('''es''')
No = ('''o''')
print('Do you want to flip another coin? ' + '\u0332y'+Yes + ' or' + ' \u0332n'+No)

Thanks for the help.

tigers486
  • 21
  • 1
  • This might be an artefact of the font that you are using - not all fonts will display combining characters correctly. Try experimenting with different fonts. Also, see [this answer](https://stackoverflow.com/a/55065815/5320906). – snakecharmerb Jan 23 '22 at 06:18
  • Thanks for the input. I changed fonts, even made sure fonts were matching in the cmd prompt, but its still not working. I also checked your link and was unable to get it working with the comments in there. I'll keep trying. – tigers486 Jan 24 '22 at 13:39

1 Answers1

1

I have the solution, proof of work

follow the below code,

from prompt_toolkit import print_formatted_text, HTML
print_formatted_text('Do you want to flip another coin? ',HTML('<u>y</u>es'),'or',HTML('<u>n</u>o'))
Zenith_1024
  • 231
  • 2
  • 14
  • No doubt your method works, as I can see it in the picture. I tried it and I am running into new problems. I'll have to try to sort it out. Last line in error ---> prompt_toolkit.output.win32.NoConsoleScreenBufferError: No Windows console found. Are you running cmd.exe? – tigers486 Jan 20 '22 at 21:48
  • I apologize, I did not run into this error. NoConsoleScreenBufferError seems to be a common occurrence for some people, but I did not get it. And yes this is CMD only, running in Admin mode – Zenith_1024 Jan 21 '22 at 04:16