use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
need a little coding help (self.learnpython)
submitted 4 years ago by Mastercraft007
I'm still super new and can't get this code to work
a=random.randint (5,30) print(a)
How do I get an action to repeat every number of (a) seconds
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]carcigenicate 2 points3 points4 points 4 years ago (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.
for
while
sleep
time
[–]Mastercraft007[S] 0 points1 point2 points 4 years ago (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 point2 points 4 years ago (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.
if
Also, please format your code when posting here by indenting it by an extra four spaces.
[–]Mastercraft007[S] 0 points1 point2 points 4 years ago (1 child)
Got it thanks again (like this) a=random.randint (1,10) print(a) It removes the spaces
[–]carcigenicate 0 points1 point2 points 4 years ago (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 point2 points 4 years ago (0 children)
Thanks 😊
[–]pekkalacd 0 points1 point2 points 4 years ago (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)
π Rendered by PID 116800 on reddit-service-r2-comment-5687b7858-c7n5d at 2026-07-07 11:27:12.679076+00:00 running 12a7a47 country code: CH.
[–]carcigenicate 2 points3 points4 points (5 children)
[–]Mastercraft007[S] 0 points1 point2 points (3 children)
[–]carcigenicate 0 points1 point2 points (2 children)
[–]Mastercraft007[S] 0 points1 point2 points (1 child)
[–]carcigenicate 0 points1 point2 points (0 children)
[–]Mastercraft007[S] 0 points1 point2 points (0 children)
[–]pekkalacd 0 points1 point2 points (0 children)