Complete the codeExercise 6/6Elementary20 XP

A safe conversion to a number

Task

The function na_cislo(text) should return the text converted to a whole number, or 0 if that is not possible. Fill in ___.

Examples

  • Call

    print(na_cislo("42"))

    Expected output

    42
  • Call

    print(na_cislo("pes"))

    Expected output

    0

Rules

  • Replace ___ with the right code.

After you submit, 3 hidden tests will also check your solution: empty text, a negative number, a decimal number.

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.