Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Another one
#1
I had another problem.

SENTINEL = 0

#Function uses modulus equation to determine if number is even or not
def is_even(num):
    if num % 2 == 0:
        return True
    else:
        return False

#if this input value returns true then print
is_even_number = is_even(int(input("Enter a number: ")))
while is_even_number>SENTINEL
    if True:
        print("Even")
    is_even_number = is_even(int(input("Enter a number: ")))
    else:
        print("Odd")
    is_even_number = is_even(int(input("Enter a number: ")))
    if is_even_number==0:
        break
        print("Done!")
Error:
File "main.py", line 12 while is_even_number>SENTINEL ^ SyntaxError: invalid syntax
Reply
#2
Missing colon.
Reply
#3
There are plenty of problems with this code, apart from obvious missing colon that cause this error right now.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020