Hey all. this is my first day python programming (been programming java for almost a year tho) and I was trying to put together the classic "shout" method. so far it is like this:

import time

def shout(string):
    for c in string:
        print("Gimme a " + c)
        print(c + "!")
        time.sleep(1)
    print("\nWhat's that spell... " + string + "!")
    
shout("COUGARS")

Basically you can see what it does... Spells out the word in cheerleader fashion. Anyway the thing I was wondering is if I could get the program to pause for a second in between the "What does that spell..." and the string. so it would go like this:

What does that spell... <one second pause> COUGARS!

Any help? Seems trivial but I haven't been able to figure it out :confused:

Recommended Answers

All 3 Replies

Member Avatar for sravan953
import time

def shout(string):
    for c in string:
        print("Gimme a " + c)
        print(c + "!")
        time.sleep(1)
    print("\nWhat's that spell... ")
    time.sleep(1)
    print(" COUGARS!")
    
shout("COUGARS")

Yeah that would work, except the last "COUGARS" would be on a seperate line, if you wanted it to stay on the same line as
"What does it spell..." then you need to use some arguments like:

print("What does it spell...", end = " ")

This makes the ending of the line a space rather then the default newline, therefore next time you go and use the print function to print the "COUGARS" you would have it all on one line.

Member Avatar for sravan953

I also vaguely remember that we can use a comma...is it like this:

.
.

    print("\nWhat's that spell... "),
    time.sleep(1)
    print(" COUGARS!")
    
shout("COUGARS")
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.