Why is printf() giving a strange output in python?

Those extra '1's at the end of each number are the return value from printf, which returns the number of chars that it prints. The return value of a function called in the interactive interpreter is automatically printed (unless it’s None).

In fact, the interactive interpreter prints any non-None expression that isn’t assigned. And of course it adds a newline to those expressions, which explains why the output in your first code block is on separate lines.

Your pr function doesn’t have a return statement, so it returns None, and thus no extra stuff gets printed.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)