| | |
pause and print same line
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
![]() |
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:
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
Python Syntax (Toggle Plain Text)
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
Python Syntax (Toggle Plain Text)
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:
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.
"What does it spell..." then you need to use some arguments like:
python Syntax (Toggle Plain Text)
print("What does it spell...", end = " ")
Make it idiot proof and someone will make a better idiot.
Check out my Site | and join us on IRC | Python Specific IRC
Check out my Site | and join us on IRC | Python Specific IRC
I also vaguely remember that we can use a comma...is it like this:
Python Syntax (Toggle Plain Text)
. . print("\nWhat's that spell... "), time.sleep(1) print(" COUGARS!") shout("COUGARS")
![]() |
Similar Threads
- Print line number (Python)
- Print on same line (w/o whitepace) (Python)
- Print Certain line in C (C)
- Stored text does not print out with line breaks.. (PHP)
- read & print only first & last line of txt file (Python)
- need help error checking my Line editor functions (C++)
Other Threads in the Python Forum
- Previous Thread: Programming Language Choice
- Next Thread: Calling grep from within python
Views: 664 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for Python
abrupt apache application argv beginner binary calculator character code command cursor cx-freeze development dictionary dynamic error event examples excel file float format ftp function google gui hints homework ideas import input java keyboard launcher line linux list lists loop microphone mouse movingimageswithpygame newb number numbers obexftp output parsing path permissions phonebook port prime program programming projects py2exe pygame pyglet pyqt pysimplewizard python random recursion recursive refresh return reverse scrolledtext session shebang signal simple sprite ssh string strings table terminal text thread threading time tkinter tlapse trick tuple tutorial ubuntu unicode unit urllib urllib2 valueerror variable verify voip windows wordgame wxpython





