printing a character at the end
how to print a character at the end of the line in console? I don't mean at the end of the string , I mean at the end of the line of console like how I print asterisk below: *
shokin touch, to print as you mentioned, we need to know the console size (columns). this can be done like shown in the sample code: (credits to Jayakrishna🇮🇳 for mentioning string.rjust(...) ! ) import os size = os.get_terminal_size() # size holds the values for columns ( size ) and for rows (size ) print("this is the end".rjust(size)) # the number of rows and columns in the console depends on the screen size, font size and font type.
I think this is exactly what you want, but unfortunately it doesn't run at Sololearn. https://code.sololearn.com/cD4B5NOP1JBv/?ref=app
list = ["hello world", "hi world"] for i in list: print(i, end="*\n") # do you want this?
@Jay Matthews @Mafdi No I mentioned that I don't mean at the end of string , I literally mean at the end of the one line in python console, you can imagine it like all the line except of last character is space and last character is something I want like asterisk
print(" " * 10 + "Hi") # like this?
@Mafdi it also does the same thing , it append the hi at the end of string not the line. also we don't know many spaces are there in the line
How do I generate a list with <N> unique elements randomly selected from another (already existing) list?
Given three integer matrices A(m*n),B(m*n) and C(m*n) . Print the one with more zero elements. beside code
I'm coding this for hours & can't make the value of the 5 random numbers round off to 2 decimal places like in the examples
Overloading + operator