Understand how to output text strings

From Computer Science Wiki
Python programming language[1]

This page is meant to be used in conjunction with our excellent resource for learning python

For this topic we are learning how to output text string to the screen. You can also output text strings to a file (but that is a different lesson).

You will also learn how to comment your code.

# a normal hello world print function in python:
print("hello world")
print("from Warsaw")

# This is a handy to print many characters X number of times. I like to use this to visually separate output. 
print("=" * 25)

# we will now look at the end keyword argument:
print("hello world", end='')
print("from Warsaw")
print("=" * 25)

# let's try a different end keyword argument:
print("hello world", end=' -- foo --')
print("from Warsaw")
print("=" * 25)

# we will now look at the sep keyword argument (what should we output between strings)
print("Hello","world", sep='..')
print("from","Warsaw", sep='--')


If you are still stuck, or you have other questions, you may want to ask a question on our discussion board.

References[edit]