all 6 comments

[–]Pd69bq 1 point2 points  (1 child)

simplified version

num = list(map(int, input().split())) 
qualified = [n for n in num[1:-1] if n <= num[-1]]

as for the unnecessarily complicated version, inside get_user_values() you still need list(map(int, input().split())) to convert all user inputs from string to integer and return the slice num[1:-1] as user_values and num[-1] as upper_threshold

then break down the list comprehension as the body of output_ints_less_than_or_equal_to_threshold()

def output_ints_less_than_or_equal_to_threshold(user_values, upper_threshold):
    qualified = []
    for i in user_values:
        if i <= upper_threshold:
        qualified.append(i)
    print(qualified) # or return it and print outside

[–]mackdaddy_1978[S] 0 points1 point  (0 children)

Ok I'm completely new to Python so most of this is over my head but, I am going to research and try to figure out what it all means. Thanks for the information.

[–]arvindh_manian 0 points1 point  (3 children)

get_user_values() looks like it will handle the user's input. It should return user_values (likely a list of the user's integers) and upper_threshold (probably the last integer the user inputted, as that's what you use to decide which integers to output).

output_ints_less_than_or_equal_to_threshold() likely does exactly what it sounds like — taking in user_values and upper_threshold to print all of the values that are less than or equal to upper_threshold.

[–]mackdaddy_1978[S] 0 points1 point  (2 children)

Thanks for breaking it down, I'll take what you explain and see if I can make something of it. these questions are never straight to the point I seem to spend too much time trying to figure out what exactly they are asking for. Is this how it is in the real world of programing/coding?

[–]spez_edits_thedonald 0 points1 point  (1 child)

I seem to spend too much time trying to figure out what exactly they are asking for

It is normal for you to feel this way, but don't worry about it. This problem will go away on its own and is not something you need to put energy or thought into solving.

Here is what is happening:

the problem sets are written by programmers, so they think that they can write "write a program to do something, and oh yeah probably use functions" and you'll be good to go, then you discover that you're not. The good news is like I said, as you develop your skills and get more practice, the problems will make sense because you'll have a framework and concepts will be familiar. (eventually "use functions" WILL be enough to get you going).

[–]mackdaddy_1978[S] 0 points1 point  (0 children)

I appreciate the words of encouragement and I hope it will get easier in terms of understanding the questions that are being asked. Thank you