-9

I'm new to python, and don't know much about loops. How would I make an infinite printing loop?

magicpenguin
  • 1
  • 1
  • 1
  • 1
  • 2
    `while True: print(x)` Don't do that though. – logic Apr 29 '15 at 00:52
  • 5
    I'd leave it at just "Don't do that." – TigerhawkT3 Apr 29 '15 at 00:53
  • @TigerhawkT3 This question is going to get closed lol, let the OP have some fun ;) – logic Apr 29 '15 at 00:54
  • Well, there are reasons you might want to do that—say `x` is an expression that takes 3 seconds to calculate, and you want it to keep printing a value every 3 seconds until you hit Ctrl-C or the other side closes the pipe or whatever… But I doubt the OP has one of those reasons. – abarnert Apr 29 '15 at 00:55
  • just a guess, I think OP might want infinite loop printing with **time interval** between each print, and he didn't know how to describe it in question – Neverever Apr 29 '15 at 00:55
  • Or maybe he's just testing whether Python is faster than his terminal's stdout (which can be an interesting test with Windows cmd.exe or Cygwin terminals). :) – abarnert Apr 29 '15 at 00:56
  • 1
    @abarnert True, but as of now, the question isn't detailed enough to make assumptions, and it doesn't really show any research effort. A simple Google search could answer it. – logic Apr 29 '15 at 00:57
  • @logic: Sure; as I said "I doubt the OP has one of those reasons". If he does, it's up to him to tell us what he's trying to do. – abarnert Apr 29 '15 at 01:05

1 Answers1

6

You can use this:

while True:
    print("Whatever you want to print")

This is not suggested though, because it will leave your program running forever and that is not good.

Zach Gates
  • 4,045
  • 1
  • 27
  • 51
MLavrentyev
  • 1,827
  • 2
  • 24
  • 32