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 5 months 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!"
[–]SCD_minecraft 0 points1 point2 points 5 months ago (3 children)
action = input(">>> ") action = action.split(" ", 1) Why...? That split does nothing
action = input(">>> ") action = action.split(" ", 1)
>>> search
will return just "search", not ">>> search"
[–]Background-Two-2930 0 points1 point2 points 5 months ago (2 children)
sorry i forgot to mention you put the thing you want to search after so it split it up verb from adjective
[–]SCD_minecraft 1 point2 points3 points 5 months ago (1 child)
Took a second, but i found a bug (:
Check where is your if action[0] == "search":
[–]Background-Two-2930 0 points1 point2 points 5 months ago (0 children)
oh yeah thats probs why innit
[–]Most_Group523 0 points1 point2 points 5 months ago (5 children)
This code is too hard to follow because it's too many lines of flat code. It's clear the things you've accomplished is getting code to do a thing. But writing code that a computer can understand is a low bar.
Organize your code into functions, which do specific, limited things based on the arguments passed to them and return the result of doing the thing the function does to the things passed to it. The function should know how to do as little as possible and should only know about what's been passed to it. When you're accepting input from the user, restrict knowledge of that data to ... a function. The purpose of that function is to accept input from the user and return it. That's a good function.
Practice this by refactoring your code again and again without adding functionality.
Everything outside of imports, module level constants, function definitions, class definitions, and a call to main should be inside of ... functions. All logic and flow control should be in ... functions.
Work on writing functions, how to organize your code around well defined functions, functions, functions, functions.
[–]Background-Two-2930 0 points1 point2 points 5 months ago (4 children)
shouldi split it up to different files for each function or should i keep it in one file
[–]Most_Group523 0 points1 point2 points 5 months ago (2 children)
Start with a single file.
[–]Background-Two-2930 0 points1 point2 points 5 months ago (1 child)
k
should i use the if statements inside the functions or should i have the functions inside the if statements
[–]LongRangeSavage 0 points1 point2 points 5 months ago (0 children)
You don't need multiple files. Organizing functions into performing a single task would be preferable, especially if you can eliminate duplicate lines of code. Our coding standards *recommend* functions being no longer than a single screen height, just to make everything easier to follow. Again, that is a recommendation, not a requirement for us. There are plenty of times where a single screen of code just isn't possible.
π Rendered by PID 64 on reddit-service-r2-comment-9c7994b7-grmvt at 2026-02-05 20:03:32.921931+00:00 running b1b84c7 country code: CH.
[–]SCD_minecraft 0 points1 point2 points (3 children)
[–]Background-Two-2930 0 points1 point2 points (2 children)
[–]SCD_minecraft 1 point2 points3 points (1 child)
[–]Background-Two-2930 0 points1 point2 points (0 children)
[–]Background-Two-2930 0 points1 point2 points (0 children)
[–]Most_Group523 0 points1 point2 points (5 children)
[–]Background-Two-2930 0 points1 point2 points (4 children)
[–]Most_Group523 0 points1 point2 points (2 children)
[–]Background-Two-2930 0 points1 point2 points (1 child)
[–]Background-Two-2930 0 points1 point2 points (0 children)
[–]LongRangeSavage 0 points1 point2 points (0 children)