Home >Backend Development >Python Tutorial >How to output vertically in python
Vertically output "Hello World", the entire code does not exceed 2 lines.
Example: The output is as follows(Recommended learning: Python video tutorial)
H e l l o W o r l d
It can be done using a for loop:
for name in "Hello World": print(name)
It can also be done using the join method:
print("\n".join("Hello World"))
For more Python related technical articles, please visit Python Learn in the tutorial column!
The above is the detailed content of How to output vertically in python. For more information, please follow other related articles on the PHP Chinese website!