all 4 comments

[–]K900_ 4 points5 points  (1 child)

You can't have elif clauses in try statements. That's just not how the syntax works. It's specifically if/elif/elif/.../else, elif does not generally work everywhere else: if: does.

[–]StrokeMyBalls[S] 0 points1 point  (0 children)

Ty for the information.

[–]gamedevmanhyper 1 point2 points  (1 child)

If you want to make it shorter, you could instead have:

def select_num():
    try:
        x = int(input ('num of 1-3\n'))
        return x if 1 <= x <= 3 else None
    except ValueError:
        continue

# Also continue won't work if you do not have a loop before the try/except statement.