Passing marks

Read a line of marks and print only the marks of 40 or more, in their original order.

What to build

A filtered list made with one line.

Requirements

  • Read the marks.
  • Print those of 40 or more, or NONE.

Input

One line of whole numbers from 0 to 100, separated by spaces.

Output

The passing marks separated by spaces, or NONE if nobody passed.

Constraints

Marks are from 0 to 100.

Example

Input:

72 35 90 48 61

Output:

72 90 48 61

Why it works

The if keeps the items that pass, in their original order, and an empty list is falsy, which makes the NONE case simple.

Examples

Example 1 · Input
72 35 90 48 61
Expected output
72 90 48 61
Example 2 · Input
10 20 30
Expected output
NONE

Prompts inside input() are ignored when checking, so input("n: ") is fine.

Hints

Hint 1

[m for m in marks if m >= 40] keeps the passing marks.

Hint 2

" ".join(...) needs strings, so convert each mark with str().

Solution

Show one correct solution (try it yourself first)
marks = [int(x) for x in input().split()]
passed = [m for m in marks if m >= 40]
print(" ".join(str(m) for m in passed) if passed else "NONE")

Lesson: List comprehensions →