You should read this: Pygame Tutorial
import time, sys
this load modules.
sys is for the stdout function.
time is for the sleep function.
def delay_print(s):
def is the keyword for a new function.
delay_print is the name of the function.
s is an argument.
Here is a really easy to understand example:
def coffee_mashine( coffee_beans ):
# make coffee
return coffee
for c in s:
for is the keyword for a loop.
c is a character for example: a, b, c.
s is a string for example: "Hello World"
sys.stdout.write( '%s' % c )
sys.stdout.write() is a function-call.
the first argument is a String. for example: "My char is %s"
%s is a wildcard for a variable.
%c is a variable
sys.stdout.flush()
clear the stdout.
time.sleep(0.01)
wait a short time.
Here a much easier code to do that:
import time, sys
def delay_print(s):
for c in s:
print c