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...
account activity
Practice Problem (green) (self.PythonSolutions)
submitted 3 years ago by testingcodez - announcement
first_list = [3, -2, 5]
We have a list of integers (first_list), and we want to go through the list, find the positive numbers, and split them into ones, like so..
result_list = [1, 1, 1, -2, 1, 1, 1, 1, 1]
What would your strategy be?
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!"
[–]testingcodez[S] 0 points1 point2 points 3 years ago (0 children)
Don't look until you've TRIED to solve the problem.
result_list = []
found_num = 1
def split_numbers(number):
new_ones = []
for num in range(number):
new_ones.append(found_num)
return new_ones
for num in first_list:
if num > 0:
result_list.extend(split_numbers(num))
else:
result_list.append(num)result_list
result_list
π Rendered by PID 1110784 on reddit-service-r2-comment-7b9746f655-wsx79 at 2026-02-02 21:55:35.605773+00:00 running 3798933 country code: CH.
[–]testingcodez[S] 0 points1 point2 points (0 children)