Python Question / Quiz; What is the output of the following Python code, and why? Comment your answers below!

PythonPr's tweet image. Python Question / Quiz; What is the output of the following Python code, and why? Comment your answers below!

Answer: Technically, nothing (no returns, doesn't even print quotes) Solution: `*` of str and int gives repetition of string. Eg, "Py" * 3 gives "PyPyPy" If the multiplication is by 0, means 0 repetitions of the str, ie, empty string. So, "Python" * 0 is "" When printed, +


strings aren't displayed with enclosing quotes. Hence, print("Python" * 0) is equivalent to print("") which just prints a blank line (not even the quotes.) That's the output.


United States Trends
Loading...

Something went wrong.


Something went wrong.