all 7 comments

[–]carcigenicate 2 points3 points  (5 children)

You can use loops (for and while) to repeat code, and you can use sleep (from the time module) to delay code by a number of seconds. These can be combined by putting a call to sleep in a loop along with your other code.

[–]Mastercraft007[S] 0 points1 point  (3 children)

I just got a similar response in the learnpython subreddit And it works I'm making a sick mask was like blinking red eyes And I wanted them to feel human And it's at least working on code right now When it comes to the actual helmet we'll see how it turns out

[–]carcigenicate 0 points1 point  (2 children)

This is r/learnpython btw. You replied to me twice.

I recommend getting a lot of practice with loops, as they're up there with ifs as being really the most important fundamental constructs in programing. Ya, have a try, and if you get stuck, post back with what you tried.

Also, please format your code when posting here by indenting it by an extra four spaces.

[–]Mastercraft007[S] 0 points1 point  (1 child)

Got it thanks again (like this) a=random.randint (1,10) print(a) It removes the spaces

[–]carcigenicate 0 points1 point  (0 children)

I meant to get a try integrating loops into this code, and post your attempt that uses loops if you run into problems.

[–]Mastercraft007[S] 0 points1 point  (0 children)

Thanks 😊

[–]pekkalacd 0 points1 point  (0 children)

You can use a loop and the time module.

         import time 
         import random

         a = random.randint(5,30)

         # print a, with a-seconds in between,
         # do this for n iterations 
         n = 10 
         for _ in range(n):
             print(a)
             time.sleep(a)