-4

I had tried to figure out the problem using different techniques, but the problem persist.



#-*-coding:utf8;-*-

#qpy:console

print("Welcome to number checking program")

number = int(input("Please enter the number that you to want check: "))

if number ℅ 2 != 0:

    print(f"{number} is an odd number")

elif number % 2 == 0:

    print(f"{number} is an even number.")

else:

    print(f"Sorry, {number} is an invalid number")

I was expecting the program to display to user the type of number he/she entered.

Markus
  • 3
  • 2
  • [ask] and [mre] – Julien Aug 23 '23 at 05:58
  • show the error on the line – Muhammad Waqar Anwar Aug 23 '23 at 05:59
  • Welcome to Stack Overflow. Please read [How to Ask](https://stackoverflow.com/questions/how-to-ask). We do not find the bug for you here; we require a specific question - which will come out of your best attempt to [understand](https://meta.stackoverflow.com/q/261592/) and [locate](https://ericlippert.com/2014/03/05) a specific problem, and showcase it in a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). – Francesco Aug 23 '23 at 05:59
  • 4
    **Typo**: on your `if number ℅ 2 != 0` line your `%` character is not the actual ASCII one. Replace it with one typed from your keyboard. – Abdul Aziz Barkat Aug 23 '23 at 06:12
  • 2
    Also, note that your `else:` condition can NEVER be hit. Every integer will match one of the two clauses. – Tim Roberts Aug 23 '23 at 06:23
  • Thanks @TimRobe and everyone for your answers, I had figured the error. – Markus Aug 24 '23 at 07:53

1 Answers1

0

In line if number ℅ 2 != 0:, you seem to use the wrong symbol for '%'. Try replacing this with a typed %.

This usually happens when you copy and paste code. When you use copied code, try to ensure that all symbols are the correct character.

Also, the error message usually contains a line number which helps you to find the incorrect line (or character, in this case) at the top. For example, here the error is on line 11:

  File "/home/user/test.py", line 11
    if number ℅ 2 != 0:
              ^
SyntaxError: invalid character '℅' (U+2105)
Erik
  • 69
  • 5