+ 2
Can anyone explain
Print ("%-ns"%S)
5 Respuestas
+ 2
This is printf-style string formatting.
Each format specifier from the string before % operator will be replaced with values which go after % operator.
Your format srting has only 1 format specifier %-ns.
'%' is the format specifier symbol
'-' defines left justification
'n' is the minimum field width. (it should be a number or *)
's' says that value should be printed as string.
for example, the output of the code
S='55'
print('%-4s!!!'%S)
will be
55 !!!
where %-4s was replaced with 55 inside the field with width 4 and left justified. '!!!' are not format specifiers, they are printed as is.
+ 1
Space do not affect
0
This code is a total mess.
It should be "print" not "Print"
There should be no space between t and (.
0
Yash Raj Singh
Sometimes it does.
I saw some interpreters (low quality though) throwing errors for extra spaces after print
0
The 'n' in the format is unrecognised, and variable <S> is undefined. As it is now, the statement is non executable.