943,694 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Unsolved
  • Views: 1826
  • Python RSS
Aug 3rd, 2009
0

pause and print same line

Expand Post »
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:

Python Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 39
Solved Threads: 1
Light Poster
smoore is offline Offline
36 posts
since Feb 2009
Aug 4th, 2009
0

Re: pause and print same line

Python Syntax (Toggle Plain Text)
  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")
Reputation Points: 2
Solved Threads: 30
Posting Whiz in Training
sravan953 is offline Offline
242 posts
since May 2009
Aug 4th, 2009
0

Re: pause and print same line

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:
python Syntax (Toggle Plain Text)
  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.
Reputation Points: 264
Solved Threads: 183
Veteran Poster
Paul Thompson is offline Offline
1,095 posts
since May 2008
Aug 4th, 2009
0

Re: pause and print same line

I also vaguely remember that we can use a comma...is it like this:
Python Syntax (Toggle Plain Text)
  1. .
  2. .
  3.  
  4. print("\nWhat's that spell... "),
  5. time.sleep(1)
  6. print(" COUGARS!")
  7.  
  8. shout("COUGARS")
Reputation Points: 2
Solved Threads: 30
Posting Whiz in Training
sravan953 is offline Offline
242 posts
since May 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Python Forum Timeline: Programming Language Choice
Next Thread in Python Forum Timeline: Calling grep from within python





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC