pause and print same line

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Feb 2009
Posts: 36
Reputation: smoore is an unknown quantity at this point 
Solved Threads: 1
smoore's Avatar
smoore smoore is offline Offline
Light Poster

pause and print same line

 
0
  #1
Aug 3rd, 2009
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:

  1. import time
  2.  
  3. def shout(string):
  4. for c in string:
  5. print("Gimme a " + c)
  6. print(c + "!")
  7. time.sleep(1)
  8. print("\nWhat's that spell... " + string + "!")
  9.  
  10. 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
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 232
Reputation: sravan953 has a little shameless behaviour in the past 
Solved Threads: 28
sravan953's Avatar
sravan953 sravan953 is offline Offline
Posting Whiz in Training

Re: pause and print same line

 
0
  #2
Aug 4th, 2009
  1. import time
  2.  
  3. def shout(string):
  4. for c in string:
  5. print("Gimme a " + c)
  6. print(c + "!")
  7. time.sleep(1)
  8. print("\nWhat's that spell... ")
  9. time.sleep(1)
  10. print(" COUGARS!")
  11.  
  12. shout("COUGARS")
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 950
Reputation: Paul Thompson has a spectacular aura about Paul Thompson has a spectacular aura about 
Solved Threads: 147
Sponsor
Paul Thompson's Avatar
Paul Thompson Paul Thompson is offline Offline
previously paulthom12345

Re: pause and print same line

 
0
  #3
Aug 4th, 2009
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:
  1. 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.
Make it idiot proof and someone will make a better idiot.
Check out my Site | and join us on IRC | Python Specific IRC
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 232
Reputation: sravan953 has a little shameless behaviour in the past 
Solved Threads: 28
sravan953's Avatar
sravan953 sravan953 is offline Offline
Posting Whiz in Training

Re: pause and print same line

 
0
  #4
Aug 4th, 2009
I also vaguely remember that we can use a comma...is it like this:
  1. .
  2. .
  3.  
  4. print("\nWhat's that spell... "),
  5. time.sleep(1)
  6. print(" COUGARS!")
  7.  
  8. shout("COUGARS")
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 664 | Replies: 3
Thread Tools Search this Thread



Tag cloud for Python
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC