Safe Conversion

Lab Python Beginner 10 points

Read n lines. For each, print the number doubled if it is an integer, otherwise invalid: TEXT.

Input

Line 1: n. Then n lines.

Output

n lines.

Example

Input

4
5
abc
-3
1.5

Output

10
invalid: abc
-6
invalid: 1.5
Sample input available Sample output available
Editor
Python

Hints

int("abc") raises ValueError.

Put the risky call inside try: and handle it in except ValueError:.

Solution explanation

Catch the specific exception you expect, not every possible error.

Show solution
for _ in range(int(input())):
    text = input()
    try:
        print(int(text) * 2)
    except ValueError:
        print(f"invalid: {text}")
Output
Answer
HOME LEARN COMMUNITY DASHBOARD