Ask coding questions

← Back to all posts
Why does Repl keep doing?
AhmadSultan (0)

Hi, let me introduce myself I am Ahmad and I was writing this try, except the block of code and repl suddenly tells me this isn't defined. Is this function not added or is it just repl randomly doing this.

Comments
hotnewtop
Coder100 (16983)

You must also have valid syntax before a try statement.

Try this:

print("Hello were trivia explosion it's a pleasure to meet you!")

try:
  
  age = int(input("Enter In your age:"))
  
except:
  print("Invalid Character")

don't forget to call the function input so that it actually prints stuff to the screen.

AhmadSultan (0)

Thank You So Much, kind of new to programming.

RYANTADIPARTHI (6000)

Solution

your error is actually on line 6. It's because you forgot to add an extra ). You also need to specify input. If you are asking questions. Try this code.

print("Hello were trivia explosion it's a pleasure to meet you!")

try:
    age = int(input("Enter In your age:"))
except ValueError:
    print("Invalid Character")

like that.
That should work