Write a programElementary20 XPExercise 1/15

Elements that occur only once

Task

The program generates a list of 20 random whole numbers from 1 to 15 and prints the elements that occur in it only once.

Split it into functions the tests call directly:

  • vygeneruj() returns a list of 20 random whole numbers from 1 to 15,
  • iba_raz(zoznam) returns a new list of the elements that occur exactly once, in the order they appear. It does not change the original list.

What the program should do

iba_raz([3, 1, 3, 2]) returns [1, 2].

Examples

  • Call

    print(iba_raz([3, 1, 3, 2]))

    Expected output

    [1, 2]
  • Call

    z = vygeneruj()
    print(type(z) == list, len(z) == 20, all(type(x) == int and 1 <= x <= 15 for x in z))
    print(len({tuple(vygeneruj()) for _ in range(20)}) > 1)

    Expected output

    True True True
    True

After you submit, 5 hidden tests will also check your solution: all elements equal, no repeats, an empty list, the order of the result, the original list stays.

Python starts the first time you run code.

Ctrl+Enter runs the program. Tab indents. Press Esc, then Tab, to leave the editor.

Input (stdin)

Each line = one call to input().

Output

Hints

Try it yourself first. Each hint reveals a little more - and lowers the reward a little.

Signed out, hints are free - but no XP is awarded either.

Solution

The solution unlocks after the last hint.