Hello, the code I am trying is completely off as I am doing this in python---what is the correct way to write a code for this kind of problem? Thanks truly it means more than you know. I'm trying to learn as quickly as possible. Here is the problem: Output values in a list below a user-defined amount Write a program that first gets a list of integers from the input. The input begins with an integer indicating the number of integers that follow. Then, get the last value from the input, which indicates a threshold. Output all integers less than or equal to that last threshold value. Ex: If the input is: 5 50 60 140 200 75 100 the output is: 50,60,75, The 5 indicates that there are five integers in the list, namely 50, 60, 140, 200, and 75. The 100 indicates that the program should output all integers less than or equal to 100, so the program outputs 50, 60, and 75. For coding simplicity, follow every output value by a comma, including the last one. Such functionality is common on sites like Amazon, where a user can filter results.



Warm regards, and thanks truly, Lily



Here is the code I tried for python/python 3 that I need help with greatly, because the list isn’t printing horizontally for the Zybooks simulator.

# reading input from user

s = input()

# splitting the string by space

splits = s.split(" ")

# calculating the size

n = int(splits[0])

# computing the values for list

lst = []

for i in range(n):

lst.append(int(splits[i + 1]))

# extracting the threshold from splits

threshold = int(splits[-1])

# looping through each value in list

for value in lst:

# checking value is less than or equal to that last threshold value.

if value <= threshold:

# printing the value ends with comma

print(value, end=',')



This is the output I am receiving. 5 50 60 140 200 75 100,

50,

60,

75,

but the expected output must be printed horizontally. Expected output 50,60,75, Thanks again truly.