So I was trying to print this four letter text in the centre using the .center() method in python. I was able to achieve that for my pc by inputting the value of 120 but that might not be the case for all pcs as well as different compilers. I tried to see if there was a program to get the dimensions but the only working one was for windows and even that didn't work well due to variable string sizes. I wanted to know if there was a program that could work across all platforms and then use that to print my string which is say a four letter string "HERO" in the center of the string.
from win32api import GetSystemMetrics
Width = GetSystemMetrics(0)) print("HERO".center(Width))
I tried doing this and even then the result was not my intended one perhaps because the dimensions were in pixels and the center method works with strings. Also this one wouldn't work on mobiles as well.
print("HERO".center(120))
Works just fine but that is again limited to my specific laptop.
So I wanted a solution that could work across all platforms and if possible doesn't really involve the installation of additional libraries.