How to display the list in the Return function – like this?
ok 1
OK 2.
OK 3.
Not ok 4.
Now the list is displayed like this:
[ok ', 1], [' ok ', 2], [' ok ', 3] ['not OK', 4]]
Function itself
def msg ():
MES = []
FOR NUMBER IN [1,2,3,4]:
IF Number & LT; 4:
MES.APPEND (['OK', Number])
ELSE:
Mes.APPEND (['not OK', Number])
Return Mes.
UPD:
def msg ():
MES = []
FOR NUMBER IN [1,2,3,4]:
IF Number & LT; 4:
Mes.APPEND (''. Join (MAP (STR, ['OK -', Number])))
ELSE:
Mes.APPEND (''. Join (MAP (STR, ['not OK -', Number])))
Return Mes.
output & gt; & gt; ['ok - 1', 'ok - 2', 'ok - 3', 'not ok - 4']
you need to transfer the strings to be
Answer 1, Authority 100%
That’s how:
def msg ():
MES = []
FOR NUMBER IN [1,2,3,4]:
IF Number & LT; 4:
MES.APPEND (['OK', Number])
ELSE:
Mes.APPEND (['not OK', Number])
Return Mes.
For x, y in msg ():
Print (x, y)