Ask coding questions

← Back to all posts
Loops
MATTHEWBECHTEL

Does anyone now how to loop something?

Answered by ArchieMaclean [earned 5 cycles]
View Answer
Voters
MateuszGazdzick
TELESIBISHOP
Murzikal
OathOfCode
DavidSosa3
MATTHEWBECHTEL
Comments
hotnewtop
ArchieMaclean

python:

Please upvote if this helps :)

MATTHEWBECHTEL

I will try it. Thanks. @ArchieMaclean

MATTHEWBECHTEL

Hm. I am not sure if it is perfect but definitely a nice start. Thank you. @ArchieMaclean

ArchieMaclean

@MATTHEWBECHTEL what do you mean? Is it not working for you?

MATTHEWBECHTEL

No it’s fine but my keyboard is lagging. Thanks. @ArchieMaclean

ArchieMaclean
MATTHEWBECHTEL

Is there a way to loop a certain Message though?

MATTHEWBECHTEL

Never mind, I fixed it. But do you think it will lag itself to death before it reaches 10k messages? @ArchieMaclean

Murzikal

@MATTHEWBECHTEL as in a print statement? then do

ArchieMaclean

@MATTHEWBECHTEL If you want to do a giant loop, you can use xrange, like:

IDK what you mean by 'Message' though

KieranCrockett

loops r awesome

MATTHEWBECHTEL

Ok one last question about loops. What’s the difference between range and xrange?

Murzikal

@MATTHEWBECHTEL range is python 3, xrange is py 2

Steven_The_GuyT

which language? I could probably give you an answer. Also, could you specify which type of loop? There are different loops, including for loops and while loops. Thank you!

PAULX
MATTHEWBECHTEL

Ok umm also is there a way to use Time.Sleep(1) but with a decimal as an time interval? For example: Time.Sleep(1.65) It would be super useful.

Geocube101

@MATTHEWBECHTEL It should work just as you typed it. Is it not working?

If not, try a lowercase 'T': time.sleep(value)

MATTHEWBECHTEL

No it is, but I’m just wondering if decimals work in time.sleep @Geocube101 like time.sleep(.89)

ArchieMaclean

@MATTHEWBECHTEL I think decimals work. Try it and see! If not,

may work (not sure if it works on just python repls though)

MATTHEWBECHTEL

Yes, I just realized that they work! Thank you. @ArchieMaclean

MATTHEWBECHTEL

Python.

ArchieMaclean

What language are you wanting to use?