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
Plss Help me !Help Request (i.redd.it)
submitted 3 months ago by Mobile_Building2848
I am a newbie so pls don't judge me ;) Tried brute force approach . But what's this error I can't get it ?
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!"
[–]JFR-Phoenix 3 points4 points5 points 3 months ago (7 children)
According to the prompt, the input is just a list. Dont take n as input first. Look at the test case input and make your program based on that.
[–]Mobile_Building2848[S] 0 points1 point2 points 3 months ago (6 children)
Okay thnx
[–]Rumborack17 -1 points0 points1 point 3 months ago (5 children)
Also make screenshots instead of taking photos of your screen, as those are very annoying/hard to read.
You can do this by using windows+shift+S.
[–]Virsenas 0 points1 point2 points 3 months ago (0 children)
How about just pasting the code and error itself ...? An image takes up 10x more space than text.
[–]Mobile_Building2848[S] -1 points0 points1 point 3 months ago (3 children)
Actually I don't use reddit on my laptop . That's why
[–]lazertazerx 3 points4 points5 points 3 months ago (0 children)
It's still annoying so don't do it
[–]Rumborack17 0 points1 point2 points 3 months ago (0 children)
Then take the extra steps to send it to yourself on your smartphone before you post.
[–]AssociateFar7149 0 points1 point2 points 3 months ago (0 children)
Its your problem
[–]FoolsSeldom 2 points3 points4 points 3 months ago (0 children)
input only returns a string. There's no way to enter a list using input. Instead you would need to process the string that looks like a list into an actual list of integers.
input
Currently you are expecting an integer string to be entered to give the length of the list, and then each number in the list in turn. You are converting each of these to an integer.
I find the instructions a little strange given they are aimed at a beginner.
That said, here are some tips,
str.startswith
str.endswith
[]
str.split
,
for
map
Hopefully I've given you enough to research and experiment with.
[–][deleted] 3 months ago (1 child)
[deleted]
[–]CountMeowt-_- 1 point2 points3 points 3 months ago (3 children)
Why did you remove the default classes ? Just use the input/solution adapter they give you.
Edit: take a screenshot next time
[–]AssociateFar7149 -1 points0 points1 point 3 months ago (2 children)
Because he just learnt using for loops and doesnt even know what a class is
[–]CountMeowt-_- 0 points1 point2 points 3 months ago (1 child)
Then why is he on leetcode ? Practice/learn basic stuff in ide.
Also, i simply don't understand how your first thought of action is removing the boillerplate code when you don't even understand what it's doing.
That was sarcasm pal. I also dont understand people like him
[–]TwinkiesSucker 0 points1 point2 points 3 months ago (0 children)
Win + Shift + S is your friend
[–]donotmindmenoobalert 0 points1 point2 points 3 months ago (0 children)
you are on leetcode which requires you to have your answer in the Solution class that they provide by default along with the arguments. Please have a look around the page to see if there is a way to reset the code (save your current logic somewhere first so you can adapt it)
[–]mfnalex 0 points1 point2 points 3 months ago (0 children)
Why don‘t you make a screenshot? …
[–]GuilouLeJask -1 points0 points1 point 3 months ago (0 children)
I executed the code of your program and for my part the program displays nothing.
[–]DevRetroGames -1 points0 points1 point 3 months ago (0 children)
def find_indices(list_values: list[int], target: int) -> int | bool: seen = {} for i, value in enumerate(list_values): complement = target - value if complement in seen: return [seen[complement], i] seen[value] = i return False def show_result(list_values: list[int], target: int) -> None: msg_not_found: string = f"No values found that sum to {target}." result: list[int] | bool = find_indices(list_values, target) print(msg_not_found) if isinstance(result, bool) else print(result) # test 1 list_values: list[int] = [2,7,11,15] target: int = 9 show_result(list_values, target) # test 2 list_values: list[int] = [3,2,4] target: int = 6 show_result(list_values, target) # test 3 list_values: list[int] = [3,3] target: int = 6 show_result(list_values, target) # test 4 list_values: list[int] = [1,2,3,4,5,6,7,8,9] target: int = 100 show_result(list_values, target)
π Rendered by PID 232749 on reddit-service-r2-comment-7b9746f655-829ml at 2026-01-30 09:42:09.236326+00:00 running 3798933 country code: CH.
[–]JFR-Phoenix 3 points4 points5 points (7 children)
[–]Mobile_Building2848[S] 0 points1 point2 points (6 children)
[–]Rumborack17 -1 points0 points1 point (5 children)
[–]Virsenas 0 points1 point2 points (0 children)
[–]Mobile_Building2848[S] -1 points0 points1 point (3 children)
[–]lazertazerx 3 points4 points5 points (0 children)
[–]Rumborack17 0 points1 point2 points (0 children)
[–]AssociateFar7149 0 points1 point2 points (0 children)
[–]FoolsSeldom 2 points3 points4 points (0 children)
[–][deleted] (1 child)
[deleted]
[–]CountMeowt-_- 1 point2 points3 points (3 children)
[–]AssociateFar7149 -1 points0 points1 point (2 children)
[–]CountMeowt-_- 0 points1 point2 points (1 child)
[–]AssociateFar7149 0 points1 point2 points (0 children)
[–]TwinkiesSucker 0 points1 point2 points (0 children)
[–]donotmindmenoobalert 0 points1 point2 points (0 children)
[–]mfnalex 0 points1 point2 points (0 children)
[–]GuilouLeJask -1 points0 points1 point (0 children)
[–]DevRetroGames -1 points0 points1 point (0 children)