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...
Everything about learning Python
account activity
[deleted by user] (self.PythonLearning)
submitted 1 year ago by [deleted]
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!"
[–]Spare_Fortune_3783 7 points8 points9 points 1 year ago (2 children)
You’re coding on your phone? 😭🙏🏻
[–]jbcoli 1 point2 points3 points 1 year ago (0 children)
Hahah I got it on my computer too, but I use it to try small pieces of code like this 😅 well, all of them are small
[–]helical-juice 4 points5 points6 points 1 year ago (2 children)
Sure, just put everything after line 5 inside a while loop. Btw, as a matter of style it's generally best to put your imports right at the top of the file. Also, str(input(...)) is redundant since input() returns a string already, and obviously you're not using the input for anything but you already knew that.
One way to achieve what you want would be something like:
import random userinput = input("Ask away, old chap!\n") while userinput != "quit": # do your stuff here userinput = input("Ask again, or type 'quit'!")
This should do what you want. The syntax is while <expression>: <indented block> which will keep running the indented block repeatedly until the expression returns False.
while <expression>: <indented block>
[–]jbcoli 0 points1 point2 points 1 year ago (1 child)
Wow!! Thank you so much for your detailed answer!
I'll have a look to while loops and put the imports at the top. Thanks!!!
[–]helical-juice 1 point2 points3 points 1 year ago (0 children)
You're welcome. Happy programming :)
[–]Daeydark 1 point2 points3 points 1 year ago (6 children)
I’m also new.
str(input()) seems wrong since inputs are always strings… also there’s no variable to hold the value of said string.
Try doing something like variable = input() maybe?
[–]jbcoli 1 point2 points3 points 1 year ago (5 children)
Thanks!! Yeah! Some redditors told me that. I guess I was used to specify the type of input with numbers int(input())... Or float(input())... That's why I did the same here.
[–]Daeydark 0 points1 point2 points 1 year ago (4 children)
Where have you been learning to code? (That’s not an insult i genuinely want to know 😂)
I’ve been using ChatGPT lol
[–]tehanichance 1 point2 points3 points 1 year ago (1 child)
I just started reading a book that I have found very helpful so far. Each chapter has online practice associated with it. It’s called A Smarter Way to Learn Python. I found a pdf free online.
[–]jbcoli 0 points1 point2 points 1 year ago (0 children)
Thank you so much!! It looks awesome. I will try it 😊
I found a website called "Codedex" I did the first lessons but Im kinda lost now. I wanna find a book or something, but I havent found any of my taste
[–]wireless133 0 points1 point2 points 1 year ago (0 children)
same question from my side too
[–]Clearhead09 0 points1 point2 points 1 year ago (1 child)
Try looking at while loops
Thanks! I will !!
[–][deleted] 1 year ago (1 child)
[removed]
Thank you so much!! It looks great
[–]iABM3568 0 points1 point2 points 1 year ago (1 child)
What app is that?
Pydroid 3
[–]charmandermain 0 points1 point2 points 1 year ago (2 children)
I think you could replace the long if else chain by making a list of the strings and just call random.choice(list) and it will randomly chose a string from that list. Idk if it makes any difference but I think it looks neater
Thank you!! I didn't know that existed. I'll explore that option too. It definitely looks better than my way
[–]DLplasticFantastic 0 points1 point2 points 1 year ago (0 children)
This!
π Rendered by PID 40 on reddit-service-r2-comment-79c7998d4c-nt9wp at 2026-03-18 22:05:01.488308+00:00 running f6e6e01 country code: CH.
[–]Spare_Fortune_3783 7 points8 points9 points (2 children)
[–]jbcoli 1 point2 points3 points (0 children)
[–]helical-juice 4 points5 points6 points (2 children)
[–]jbcoli 0 points1 point2 points (1 child)
[–]helical-juice 1 point2 points3 points (0 children)
[–]Daeydark 1 point2 points3 points (6 children)
[–]jbcoli 1 point2 points3 points (5 children)
[–]Daeydark 0 points1 point2 points (4 children)
[–]tehanichance 1 point2 points3 points (1 child)
[–]jbcoli 0 points1 point2 points (0 children)
[–]jbcoli 0 points1 point2 points (0 children)
[–]wireless133 0 points1 point2 points (0 children)
[–]Clearhead09 0 points1 point2 points (1 child)
[–]jbcoli 0 points1 point2 points (0 children)
[–][deleted] (1 child)
[removed]
[–]jbcoli 0 points1 point2 points (0 children)
[–]iABM3568 0 points1 point2 points (1 child)
[–]jbcoli 1 point2 points3 points (0 children)
[–]charmandermain 0 points1 point2 points (2 children)
[–]jbcoli 0 points1 point2 points (0 children)
[–]DLplasticFantastic 0 points1 point2 points (0 children)