0

Better ideas for this code?

import random a=1 while a>0 print(random.randint(0,1000000)) print("your phone does not like this")

5th Nov 2016, 11:18 AM
ThE sOuNd In YoU
ThE sOuNd In YoU - avatar
5 Respuestas
+ 2
Using a variable to get an infinite loop is not necessary, you can just use while 1: The other possibility is to use while True:
5th Nov 2016, 11:22 AM
Pierre Varlez
Pierre Varlez - avatar
+ 2
If you mean the syntax error, put a colon on: while a>0: If you aren't multi threading use Pierre's answer. ===== Otherwise it's useful for multithreading: http://stackoverflow.com/a/19790803/3981745 So you could stop it, and it's faster than an additional check in the loop.
5th Nov 2016, 11:56 AM
Kirk Schafer
Kirk Schafer - avatar
+ 1
While(a < 100): a=a+1 Print ""
6th Nov 2016, 5:00 AM
Ayoub Walsh Alden
Ayoub Walsh Alden - avatar
0
how could i improve it?
5th Nov 2016, 11:18 AM
ThE sOuNd In YoU
ThE sOuNd In YoU - avatar
0
is seams that it doesn't work for me... Pierre Varlez
5th Nov 2016, 11:23 AM
ThE sOuNd In YoU
ThE sOuNd In YoU - avatar